1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-02 12:20:51 +00:00

Remove "long" variables from the TCP stack (not including the modular

congestion control framework).

Reviewed by:	gnn, lstewart (partial)
Sponsored by:	Juniper Networks, Netflix
Differential Revision:	(multiple)
Tested by:	Limelight, Netflix
This commit is contained in:
Jonathan T. Looney 2016-10-06 16:28:34 +00:00
parent 0dda76b82b
commit 3ac125068a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=306769
15 changed files with 140 additions and 139 deletions

View File

@ -374,7 +374,7 @@ cdg_exp_backoff_scale_handler(SYSCTL_HANDLER_ARGS)
return (sysctl_handle_int(oidp, arg1, arg2, req));
}
static inline unsigned long
static inline uint32_t
cdg_window_decrease(struct cc_var *ccv, unsigned long owin, unsigned int beta)
{
@ -460,7 +460,7 @@ cdg_cong_signal(struct cc_var *ccv, uint32_t signal_type)
cdg_data->shadow_w = cdg_window_decrease(ccv,
cdg_data->shadow_w, RENO_BETA);
CCV(ccv, snd_ssthresh) = ulmax(cdg_data->shadow_w,
CCV(ccv, snd_ssthresh) = max(cdg_data->shadow_w,
cdg_window_decrease(ccv, CCV(ccv, snd_cwnd),
V_cdg_beta_loss));

View File

@ -403,8 +403,8 @@ cubic_ssthresh_update(struct cc_var *ccv)
if (cubic_data->num_cong_events == 0)
CCV(ccv, snd_ssthresh) = CCV(ccv, snd_cwnd) >> 1;
else
CCV(ccv, snd_ssthresh) = (CCV(ccv, snd_cwnd) * CUBIC_BETA)
>> CUBIC_SHIFT;
CCV(ccv, snd_ssthresh) = ((u_long)CCV(ccv, snd_cwnd) *
CUBIC_BETA) >> CUBIC_SHIFT;
}

View File

@ -504,12 +504,12 @@ htcp_ssthresh_update(struct cc_var *ccv)
* subsequent congestion events, set it to cwnd * beta.
*/
if (CCV(ccv, snd_ssthresh) == TCP_MAXWIN << TCP_MAX_WINSHIFT)
CCV(ccv, snd_ssthresh) = (CCV(ccv, snd_cwnd) * HTCP_MINBETA)
>> HTCP_SHIFT;
CCV(ccv, snd_ssthresh) = ((u_long)CCV(ccv, snd_cwnd) *
HTCP_MINBETA) >> HTCP_SHIFT;
else {
htcp_recalc_beta(ccv);
CCV(ccv, snd_ssthresh) = (CCV(ccv, snd_cwnd) * htcp_data->beta)
>> HTCP_SHIFT;
CCV(ccv, snd_ssthresh) = ((u_long)CCV(ccv, snd_cwnd) *
htcp_data->beta) >> HTCP_SHIFT;
}
}

View File

@ -83,7 +83,7 @@ static void ertt_uma_dtor(void *mem, int size, void *arg);
*/
struct txseginfo {
/* Segment length. */
long len;
uint32_t len;
/* Segment sequence number. */
tcp_seq seq;
/* Time stamp indicating when the packet was sent. */
@ -366,8 +366,8 @@ ertt_packet_measurement_hook(int hhook_type, int hhook_id, void *udata,
&rtt_bytes_adjust, CORRECT_ACK);
if (txsi->flags & TXSI_TSO) {
txsi->len -= acked;
if (txsi->len > 0) {
if (txsi->len > acked) {
txsi->len -= acked;
/*
* This presumes ack for first bytes in
* txsi, this may not be true but it
@ -400,6 +400,7 @@ ertt_packet_measurement_hook(int hhook_type, int hhook_id, void *udata,
*/
break;
}
txsi->len = 0;
}
TAILQ_REMOVE(&e_t->txsegi_q, txsi, txsegi_lnk);
@ -435,7 +436,7 @@ ertt_add_tx_segment_info_hook(int hhook_type, int hhook_id, void *udata,
struct tcpopt *to;
struct tcp_hhook_data *thdp;
struct txseginfo *txsi;
long len;
uint32_t len;
int tso;
KASSERT(ctx_data != NULL, ("%s: ctx_data is NULL!", __func__));

View File

@ -215,9 +215,9 @@ tcp_trace(short act, short ostate, struct tcpcb *tp, void *ipgen,
return;
printf(
"\trcv_(nxt,wnd,up) (%lx,%lx,%lx) snd_(una,nxt,max) (%lx,%lx,%lx)\n",
(u_long)tp->rcv_nxt, tp->rcv_wnd, (u_long)tp->rcv_up,
(u_long)tp->rcv_nxt, (u_long)tp->rcv_wnd, (u_long)tp->rcv_up,
(u_long)tp->snd_una, (u_long)tp->snd_nxt, (u_long)tp->snd_max);
printf("\tsnd_(wl1,wl2,wnd) (%lx,%lx,%lx)\n",
(u_long)tp->snd_wl1, (u_long)tp->snd_wl2, tp->snd_wnd);
(u_long)tp->snd_wl1, (u_long)tp->snd_wl2, (u_long)tp->snd_wnd);
#endif /* TCPDEBUG */
}

View File

@ -470,11 +470,11 @@ tcp_hc_get(struct in_conninfo *inc, struct hc_metrics_lite *hc_metrics_lite)
* discovered path MTU. Returns 0 if no entry is found or value is not
* set.
*/
u_long
uint32_t
tcp_hc_getmtu(struct in_conninfo *inc)
{
struct hc_metrics *hc_entry;
u_long mtu;
uint32_t mtu;
if (!V_tcp_use_hostcache)
return 0;
@ -496,7 +496,7 @@ tcp_hc_getmtu(struct in_conninfo *inc)
* Creates a new entry if none was found.
*/
void
tcp_hc_updatemtu(struct in_conninfo *inc, u_long mtu)
tcp_hc_updatemtu(struct in_conninfo *inc, uint32_t mtu)
{
struct hc_metrics *hc_entry;
@ -558,16 +558,16 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
if (hc_entry->rmx_rtt == 0)
hc_entry->rmx_rtt = hcml->rmx_rtt;
else
hc_entry->rmx_rtt =
(hc_entry->rmx_rtt + hcml->rmx_rtt) / 2;
hc_entry->rmx_rtt = ((uint64_t)hc_entry->rmx_rtt +
(uint64_t)hcml->rmx_rtt) / 2;
TCPSTAT_INC(tcps_cachedrtt);
}
if (hcml->rmx_rttvar != 0) {
if (hc_entry->rmx_rttvar == 0)
hc_entry->rmx_rttvar = hcml->rmx_rttvar;
else
hc_entry->rmx_rttvar =
(hc_entry->rmx_rttvar + hcml->rmx_rttvar) / 2;
hc_entry->rmx_rttvar = ((uint64_t)hc_entry->rmx_rttvar +
(uint64_t)hcml->rmx_rttvar) / 2;
TCPSTAT_INC(tcps_cachedrttvar);
}
if (hcml->rmx_ssthresh != 0) {
@ -582,8 +582,8 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
if (hc_entry->rmx_cwnd == 0)
hc_entry->rmx_cwnd = hcml->rmx_cwnd;
else
hc_entry->rmx_cwnd =
(hc_entry->rmx_cwnd + hcml->rmx_cwnd) / 2;
hc_entry->rmx_cwnd = ((uint64_t)hc_entry->rmx_cwnd +
(uint64_t)hcml->rmx_cwnd) / 2;
/* TCPSTAT_INC(tcps_cachedcwnd); */
}
if (hcml->rmx_sendpipe != 0) {
@ -591,7 +591,8 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
hc_entry->rmx_sendpipe = hcml->rmx_sendpipe;
else
hc_entry->rmx_sendpipe =
(hc_entry->rmx_sendpipe + hcml->rmx_sendpipe) /2;
((uint64_t)hc_entry->rmx_sendpipe +
(uint64_t)hcml->rmx_sendpipe) /2;
/* TCPSTAT_INC(tcps_cachedsendpipe); */
}
if (hcml->rmx_recvpipe != 0) {
@ -599,7 +600,8 @@ tcp_hc_update(struct in_conninfo *inc, struct hc_metrics_lite *hcml)
hc_entry->rmx_recvpipe = hcml->rmx_recvpipe;
else
hc_entry->rmx_recvpipe =
(hc_entry->rmx_recvpipe + hcml->rmx_recvpipe) /2;
((uint64_t)hc_entry->rmx_recvpipe +
(uint64_t)hcml->rmx_recvpipe) /2;
/* TCPSTAT_INC(tcps_cachedrecvpipe); */
}
@ -636,7 +638,7 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
TAILQ_FOREACH(hc_entry, &V_tcp_hostcache.hashbase[i].hch_bucket,
rmx_q) {
sbuf_printf(&sb,
"%-15s %5lu %8lu %6lums %6lums %8lu %8lu %8lu %4lu "
"%-15s %5u %8u %6lums %6lums %8u %8u %8u %4lu "
"%4lu %4i\n",
hc_entry->ip4.s_addr ? inet_ntoa(hc_entry->ip4) :
#ifdef INET6
@ -646,9 +648,9 @@ sysctl_tcp_hc_list(SYSCTL_HANDLER_ARGS)
#endif
hc_entry->rmx_mtu,
hc_entry->rmx_ssthresh,
msec(hc_entry->rmx_rtt *
msec((u_long)hc_entry->rmx_rtt *
(RTM_RTTUNIT / (hz * TCP_RTT_SCALE))),
msec(hc_entry->rmx_rttvar *
msec((u_long)hc_entry->rmx_rttvar *
(RTM_RTTUNIT / (hz * TCP_RTTVAR_SCALE))),
hc_entry->rmx_cwnd,
hc_entry->rmx_sendpipe,

View File

@ -48,22 +48,22 @@ struct hc_head {
struct hc_metrics {
/* housekeeping */
TAILQ_ENTRY(hc_metrics) rmx_q;
struct hc_head *rmx_head; /* head of bucket tail queue */
struct in_addr ip4; /* IP address */
struct in6_addr ip6; /* IP6 address */
uint32_t ip6_zoneid; /* IPv6 scope zone id */
struct hc_head *rmx_head; /* head of bucket tail queue */
struct in_addr ip4; /* IP address */
struct in6_addr ip6; /* IP6 address */
uint32_t ip6_zoneid; /* IPv6 scope zone id */
/* endpoint specific values for tcp */
u_long rmx_mtu; /* MTU for this path */
u_long rmx_ssthresh; /* outbound gateway buffer limit */
u_long rmx_rtt; /* estimated round trip time */
u_long rmx_rttvar; /* estimated rtt variance */
u_long rmx_cwnd; /* congestion window */
u_long rmx_sendpipe; /* outbound delay-bandwidth product */
u_long rmx_recvpipe; /* inbound delay-bandwidth product */
uint32_t rmx_mtu; /* MTU for this path */
uint32_t rmx_ssthresh; /* outbound gateway buffer limit */
uint32_t rmx_rtt; /* estimated round trip time */
uint32_t rmx_rttvar; /* estimated rtt variance */
uint32_t rmx_cwnd; /* congestion window */
uint32_t rmx_sendpipe; /* outbound delay-bandwidth product */
uint32_t rmx_recvpipe; /* inbound delay-bandwidth product */
/* TCP hostcache internal data */
int rmx_expire; /* lifetime for object */
u_long rmx_hits; /* number of hits */
u_long rmx_updates; /* number of updates */
int rmx_expire; /* lifetime for object */
u_long rmx_hits; /* number of hits */
u_long rmx_updates; /* number of updates */
};
struct tcp_hostcache {

View File

@ -1496,7 +1496,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
{
int thflags, acked, ourfinisacked, needoutput = 0, sack_changed;
int rstreason, todrop, win;
u_long tiwin;
uint32_t tiwin;
uint16_t nsegs;
char *s;
struct in_conninfo *inc;
@ -1736,7 +1736,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
*/
if ((to.to_flags & TOF_TS) != 0 &&
to.to_tsecr) {
u_int t;
uint32_t t;
t = tcp_ts_getticks() - to.to_tsecr;
if (!tp->t_rttlow || tp->t_rttlow > t)
@ -2025,7 +2025,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
(TF_RCVD_SCALE|TF_REQ_SCALE)) {
tp->rcv_scale = tp->request_r_scale;
}
tp->rcv_adv += imin(tp->rcv_wnd,
tp->rcv_adv += min(tp->rcv_wnd,
TCP_MAXWIN << tp->rcv_scale);
tp->snd_una++; /* SYN is acked */
/*
@ -2655,7 +2655,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
*/
cc_ack_received(tp, th, nsegs,
CC_DUPACK);
u_long oldcwnd = tp->snd_cwnd;
uint32_t oldcwnd = tp->snd_cwnd;
tcp_seq oldsndmax = tp->snd_max;
u_int sent;
int avail;
@ -2785,7 +2785,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
* huge RTT and blow up the retransmit timer.
*/
if ((to.to_flags & TOF_TS) != 0 && to.to_tsecr) {
u_int t;
uint32_t t;
t = tcp_ts_getticks() - to.to_tsecr;
if (!tp->t_rttlow || tp->t_rttlow > t)
@ -2834,7 +2834,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
ourfinisacked = 1;
} else {
mfree = sbcut_locked(&so->so_snd, acked);
if (tp->snd_wnd >= (u_long) acked)
if (tp->snd_wnd >= (uint32_t) acked)
tp->snd_wnd -= acked;
else
tp->snd_wnd = 0;
@ -2995,7 +2995,7 @@ tcp_do_segment(struct mbuf *m, struct tcphdr *th, struct socket *so,
* but if two URG's are pending at once, some out-of-band
* data may creep in... ick.
*/
if (th->th_urp <= (u_long)tlen &&
if (th->th_urp <= (uint32_t)tlen &&
!(so->so_options & SO_OOBINLINE)) {
/* hdr drop is delayed */
tcp_pulloutofband(so, th, m, drop_hdrlen);
@ -3560,7 +3560,7 @@ tcp_mss_update(struct tcpcb *tp, int offer, int mtuoffer,
struct hc_metrics_lite *metricptr, struct tcp_ifcap *cap)
{
int mss = 0;
u_long maxmtu = 0;
uint32_t maxmtu = 0;
struct inpcb *inp = tp->t_inpcb;
struct hc_metrics_lite metrics;
#ifdef INET6
@ -3706,7 +3706,7 @@ void
tcp_mss(struct tcpcb *tp, int offer)
{
int mss;
u_long bufsize;
uint32_t bufsize;
struct inpcb *inp;
struct socket *so;
struct hc_metrics_lite metrics;
@ -3775,8 +3775,8 @@ int
tcp_mssopt(struct in_conninfo *inc)
{
int mss = 0;
u_long maxmtu = 0;
u_long thcmtu = 0;
uint32_t thcmtu = 0;
uint32_t maxmtu = 0;
size_t min_protoh;
KASSERT(inc != NULL, ("tcp_mssopt with NULL in_conninfo pointer"));
@ -3821,7 +3821,7 @@ void
tcp_newreno_partial_ack(struct tcpcb *tp, struct tcphdr *th)
{
tcp_seq onxt = tp->snd_nxt;
u_long ocwnd = tp->snd_cwnd;
uint32_t ocwnd = tp->snd_cwnd;
u_int maxseg = tcp_maxseg(tp);
INP_WLOCK_ASSERT(tp->t_inpcb);

View File

@ -142,7 +142,7 @@ SYSCTL_INT(_net_inet_tcp, OID_AUTO, sendbuf_max, CTLFLAG_VNET | CTLFLAG_RW,
static void inline hhook_run_tcp_est_out(struct tcpcb *tp,
struct tcphdr *th, struct tcpopt *to,
long len, int tso);
uint32_t len, int tso);
static void inline cc_after_idle(struct tcpcb *tp);
/*
@ -150,7 +150,7 @@ static void inline cc_after_idle(struct tcpcb *tp);
*/
static void inline
hhook_run_tcp_est_out(struct tcpcb *tp, struct tcphdr *th,
struct tcpopt *to, long len, int tso)
struct tcpopt *to, uint32_t len, int tso)
{
struct tcp_hhook_data hhook_data;
@ -185,7 +185,8 @@ int
tcp_output(struct tcpcb *tp)
{
struct socket *so = tp->t_inpcb->inp_socket;
long len, recwin, sendwin;
int32_t len;
uint32_t recwin, sendwin;
int off, flags, error = 0; /* Keep compiler happy */
struct mbuf *m;
struct ip *ip = NULL;
@ -277,11 +278,10 @@ tcp_output(struct tcpcb *tp)
p = NULL;
if ((tp->t_flags & TF_SACK_PERMIT) && IN_FASTRECOVERY(tp->t_flags) &&
(p = tcp_sack_output(tp, &sack_bytes_rxmt))) {
long cwin;
uint32_t cwin;
cwin = min(tp->snd_wnd, tp->snd_cwnd) - sack_bytes_rxmt;
if (cwin < 0)
cwin = 0;
cwin =
imax(min(tp->snd_wnd, tp->snd_cwnd) - sack_bytes_rxmt, 0);
/* Do not retransmit SACK segments beyond snd_recover */
if (SEQ_GT(p->end, tp->snd_recover)) {
/*
@ -300,10 +300,10 @@ tcp_output(struct tcpcb *tp)
goto after_sack_rexmit;
} else
/* Can rexmit part of the current hole */
len = ((long)ulmin(cwin,
len = ((int32_t)ulmin(cwin,
tp->snd_recover - p->rxmit));
} else
len = ((long)ulmin(cwin, p->end - p->rxmit));
len = ((int32_t)ulmin(cwin, p->end - p->rxmit));
off = p->rxmit - tp->snd_una;
KASSERT(off >= 0,("%s: sack block to the left of una : %d",
__func__, off));
@ -376,17 +376,17 @@ tcp_output(struct tcpcb *tp)
*/
if (sack_rxmit == 0) {
if (sack_bytes_rxmt == 0)
len = ((long)ulmin(sbavail(&so->so_snd), sendwin) -
len = ((int32_t)ulmin(sbavail(&so->so_snd), sendwin) -
off);
else {
long cwin;
int32_t cwin;
/*
* We are inside of a SACK recovery episode and are
* sending new data, having retransmitted all the
* data possible in the scoreboard.
*/
len = ((long)ulmin(sbavail(&so->so_snd), tp->snd_wnd) -
len = ((int32_t)min(sbavail(&so->so_snd), tp->snd_wnd) -
off);
/*
* Don't remove this (len > 0) check !
@ -402,7 +402,7 @@ tcp_output(struct tcpcb *tp)
sack_bytes_rxmt;
if (cwin < 0)
cwin = 0;
len = lmin(len, cwin);
len = imin(len, cwin);
}
}
}
@ -566,7 +566,8 @@ tcp_output(struct tcpcb *tp)
flags &= ~TH_FIN;
}
recwin = sbspace(&so->so_rcv);
recwin = lmin(lmax(sbspace(&so->so_rcv), 0),
(long)TCP_MAXWIN << tp->rcv_scale);
/*
* Sender silly window avoidance. We transmit under the following
@ -592,7 +593,7 @@ tcp_output(struct tcpcb *tp)
*/
if (!(tp->t_flags & TF_MORETOCOME) && /* normal case */
(idle || (tp->t_flags & TF_NODELAY)) &&
len + off >= sbavail(&so->so_snd) &&
(uint32_t)len + (uint32_t)off >= sbavail(&so->so_snd) &&
(tp->t_flags & TF_NOPUSH) == 0) {
goto send;
}
@ -643,10 +644,10 @@ tcp_output(struct tcpcb *tp)
* taking into account that we are limited by
* TCP_MAXWIN << tp->rcv_scale.
*/
long adv;
int32_t adv;
int oldwin;
adv = min(recwin, (long)TCP_MAXWIN << tp->rcv_scale);
adv = recwin;
if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt)) {
oldwin = (tp->rcv_adv - tp->rcv_nxt);
adv -= oldwin;
@ -661,9 +662,9 @@ tcp_output(struct tcpcb *tp)
if (oldwin >> tp->rcv_scale >= (adv + oldwin) >> tp->rcv_scale)
goto dontupdate;
if (adv >= (long)(2 * tp->t_maxseg) &&
(adv >= (long)(so->so_rcv.sb_hiwat / 4) ||
recwin <= (long)(so->so_rcv.sb_hiwat / 8) ||
if (adv >= (int32_t)(2 * tp->t_maxseg) &&
(adv >= (int32_t)(so->so_rcv.sb_hiwat / 4) ||
recwin <= (so->so_rcv.sb_hiwat / 8) ||
so->so_rcv.sb_hiwat <= 8 * tp->t_maxseg))
goto send;
}
@ -950,7 +951,8 @@ tcp_output(struct tcpcb *tp)
* emptied:
*/
max_len = (tp->t_maxseg - optlen);
if ((off + len) < sbavail(&so->so_snd)) {
if (((uint32_t)off + (uint32_t)len) <
sbavail(&so->so_snd)) {
moff = len % max_len;
if (moff != 0) {
len -= moff;
@ -1046,7 +1048,7 @@ tcp_output(struct tcpcb *tp)
mb = sbsndptr(&so->so_snd, off, len, &moff);
if (len <= MHLEN - hdrlen - max_linkhdr) {
m_copydata(mb, moff, (int)len,
m_copydata(mb, moff, len,
mtod(m, caddr_t) + hdrlen);
m->m_len += len;
} else {
@ -1066,7 +1068,8 @@ tcp_output(struct tcpcb *tp)
* give data to the user when a buffer fills or
* a PUSH comes in.)
*/
if ((off + len == sbused(&so->so_snd)) && !(flags & TH_SYN))
if (((uint32_t)off + (uint32_t)len == sbused(&so->so_snd)) &&
!(flags & TH_SYN))
flags |= TH_PUSH;
SOCKBUF_UNLOCK(&so->so_snd);
} else {
@ -1199,14 +1202,12 @@ tcp_output(struct tcpcb *tp)
* Calculate receive window. Don't shrink window,
* but avoid silly window syndrome.
*/
if (recwin < (long)(so->so_rcv.sb_hiwat / 4) &&
recwin < (long)tp->t_maxseg)
if (recwin < (so->so_rcv.sb_hiwat / 4) &&
recwin < tp->t_maxseg)
recwin = 0;
if (SEQ_GT(tp->rcv_adv, tp->rcv_nxt) &&
recwin < (long)(tp->rcv_adv - tp->rcv_nxt))
recwin = (long)(tp->rcv_adv - tp->rcv_nxt);
if (recwin > (long)TCP_MAXWIN << tp->rcv_scale)
recwin = (long)TCP_MAXWIN << tp->rcv_scale;
recwin < (tp->rcv_adv - tp->rcv_nxt))
recwin = (tp->rcv_adv - tp->rcv_nxt);
/*
* According to RFC1323 the window field in a SYN (i.e., a <SYN>
@ -1297,11 +1298,11 @@ tcp_output(struct tcpcb *tp)
#ifdef IPSEC
KASSERT(len + hdrlen + ipoptlen - ipsec_optlen == m_length(m, NULL),
("%s: mbuf chain shorter than expected: %ld + %u + %u - %u != %u",
("%s: mbuf chain shorter than expected: %d + %u + %u - %u != %u",
__func__, len, hdrlen, ipoptlen, ipsec_optlen, m_length(m, NULL)));
#else
KASSERT(len + hdrlen + ipoptlen == m_length(m, NULL),
("%s: mbuf chain shorter than expected: %ld + %u + %u != %u",
("%s: mbuf chain shorter than expected: %d + %u + %u != %u",
__func__, len, hdrlen, ipoptlen, m_length(m, NULL)));
#endif
@ -1597,7 +1598,7 @@ tcp_output(struct tcpcb *tp)
* then remember the size of the advertised window.
* Any pending ACK has now been sent.
*/
if (recwin >= 0 && SEQ_GT(tp->rcv_nxt + recwin, tp->rcv_adv))
if (SEQ_GT(tp->rcv_nxt + recwin, tp->rcv_adv))
tp->rcv_adv = tp->rcv_nxt + recwin;
tp->last_ack_sent = tp->rcv_nxt;
tp->t_flags &= ~(TF_ACKNOW | TF_DELACK);

View File

@ -75,20 +75,17 @@
* tcp_ts_getticks() in ms, should be 1ms < x < 1000ms according to RFC 1323.
* We always use 1ms granularity independent of hz.
*/
static __inline u_int
static __inline uint32_t
tcp_ts_getticks(void)
{
struct timeval tv;
u_long ms;
/*
* getmicrouptime() should be good enough for any 1-1000ms granularity.
* Do not use getmicrotime() here as it might break nfsroot/tcp.
*/
getmicrouptime(&tv);
ms = tv.tv_sec * 1000 + tv.tv_usec / 1000;
return (ms);
return (tv.tv_sec * 1000 + tv.tv_usec / 1000);
}
#endif /* _KERNEL */

View File

@ -169,7 +169,7 @@ static void tcp_do_segment_fastack(struct mbuf *, struct tcphdr *,
static void
tcp_do_fastack(struct mbuf *m, struct tcphdr *th, struct socket *so,
struct tcpcb *tp, struct tcpopt *to, int drop_hdrlen, int tlen,
int ti_locked, u_long tiwin)
int ti_locked, uint32_t tiwin)
{
int acked;
uint16_t nsegs;
@ -248,7 +248,7 @@ tcp_do_fastack(struct mbuf *m, struct tcphdr *th, struct socket *so,
*/
if ((to->to_flags & TOF_TS) != 0 &&
to->to_tsecr) {
u_int t;
uint32_t t;
t = tcp_ts_getticks() - to->to_tsecr;
if (!tp->t_rttlow || tp->t_rttlow > t)
@ -343,7 +343,7 @@ tcp_do_fastack(struct mbuf *m, struct tcphdr *th, struct socket *so,
static void
tcp_do_fastnewdata(struct mbuf *m, struct tcphdr *th, struct socket *so,
struct tcpcb *tp, struct tcpopt *to, int drop_hdrlen, int tlen,
int ti_locked, u_long tiwin)
int ti_locked, uint32_t tiwin)
{
int newsize = 0; /* automatic sockbuf scaling */
#ifdef TCPDEBUG
@ -501,7 +501,7 @@ tcp_do_fastnewdata(struct mbuf *m, struct tcphdr *th, struct socket *so,
static void
tcp_do_slowpath(struct mbuf *m, struct tcphdr *th, struct socket *so,
struct tcpcb *tp, struct tcpopt *to, int drop_hdrlen, int tlen,
int ti_locked, u_long tiwin, int thflags)
int ti_locked, uint32_t tiwin, int thflags)
{
int acked, ourfinisacked, needoutput = 0;
int rstreason, todrop, win;
@ -595,7 +595,7 @@ tcp_do_slowpath(struct mbuf *m, struct tcphdr *th, struct socket *so,
(TF_RCVD_SCALE|TF_REQ_SCALE)) {
tp->rcv_scale = tp->request_r_scale;
}
tp->rcv_adv += imin(tp->rcv_wnd,
tp->rcv_adv += min(tp->rcv_wnd,
TCP_MAXWIN << tp->rcv_scale);
tp->snd_una++; /* SYN is acked */
/*
@ -1179,7 +1179,7 @@ tcp_do_slowpath(struct mbuf *m, struct tcphdr *th, struct socket *so,
*/
cc_ack_received(tp, th, nsegs,
CC_DUPACK);
u_long oldcwnd = tp->snd_cwnd;
uint32_t oldcwnd = tp->snd_cwnd;
tcp_seq oldsndmax = tp->snd_max;
u_int sent;
int avail;
@ -1296,7 +1296,7 @@ tcp_do_slowpath(struct mbuf *m, struct tcphdr *th, struct socket *so,
* huge RTT and blow up the retransmit timer.
*/
if ((to->to_flags & TOF_TS) != 0 && to->to_tsecr) {
u_int t;
uint32_t t;
t = tcp_ts_getticks() - to->to_tsecr;
if (!tp->t_rttlow || tp->t_rttlow > t)
@ -1500,7 +1500,7 @@ tcp_do_slowpath(struct mbuf *m, struct tcphdr *th, struct socket *so,
* but if two URG's are pending at once, some out-of-band
* data may creep in... ick.
*/
if (th->th_urp <= (u_long)tlen &&
if (th->th_urp <= (uint32_t)tlen &&
!(so->so_options & SO_OOBINLINE)) {
/* hdr drop is delayed */
tcp_pulloutofband(so, th, m, drop_hdrlen);
@ -1765,7 +1765,7 @@ tcp_do_segment_fastslow(struct mbuf *m, struct tcphdr *th, struct socket *so,
int ti_locked)
{
int thflags;
u_long tiwin;
uint32_t tiwin;
char *s;
uint16_t nsegs;
int can_enter;
@ -1991,7 +1991,7 @@ tcp_do_segment_fastslow(struct mbuf *m, struct tcphdr *th, struct socket *so,
static int
tcp_fastack(struct mbuf *m, struct tcphdr *th, struct socket *so,
struct tcpcb *tp, struct tcpopt *to, int drop_hdrlen, int tlen,
int ti_locked, u_long tiwin)
int ti_locked, uint32_t tiwin)
{
int acked;
uint16_t nsegs;
@ -2109,7 +2109,7 @@ tcp_fastack(struct mbuf *m, struct tcphdr *th, struct socket *so,
*/
if ((to->to_flags & TOF_TS) != 0 &&
to->to_tsecr) {
u_int t;
uint32_t t;
t = tcp_ts_getticks() - to->to_tsecr;
if (!tp->t_rttlow || tp->t_rttlow > t)
@ -2213,7 +2213,7 @@ tcp_do_segment_fastack(struct mbuf *m, struct tcphdr *th, struct socket *so,
int ti_locked)
{
int thflags;
u_long tiwin;
uint32_t tiwin;
char *s;
struct in_conninfo *inc;
struct tcpopt to;

View File

@ -913,8 +913,8 @@ tcp_respond(struct tcpcb *tp, void *ipgen, struct tcphdr *th, struct mbuf *m,
if (tp != NULL) {
if (!(flags & TH_RST)) {
win = sbspace(&inp->inp_socket->so_rcv);
if (win > (long)TCP_MAXWIN << tp->rcv_scale)
win = (long)TCP_MAXWIN << tp->rcv_scale;
if (win > TCP_MAXWIN << tp->rcv_scale)
win = TCP_MAXWIN << tp->rcv_scale;
}
if ((tp->t_flags & TF_NOOPT) == 0)
incl_opts = true;
@ -1412,7 +1412,7 @@ tcp_discardcb(struct tcpcb *tp)
*/
if (tp->t_rttupdated >= 4) {
struct hc_metrics_lite metrics;
u_long ssthresh;
uint32_t ssthresh;
bzero(&metrics, sizeof(metrics));
/*
@ -1433,7 +1433,7 @@ tcp_discardcb(struct tcpcb *tp)
ssthresh = (ssthresh + tp->t_maxseg / 2) / tp->t_maxseg;
if (ssthresh < 2)
ssthresh = 2;
ssthresh *= (u_long)(tp->t_maxseg +
ssthresh *= (tp->t_maxseg +
#ifdef INET6
(isipv6 ? sizeof (struct ip6_hdr) +
sizeof (struct tcphdr) :
@ -2382,12 +2382,12 @@ tcp_mtudisc(struct inpcb *inp, int mtuoffer)
* is called by TCP routines that access the rmx structure and by
* tcp_mss_update to get the peer/interface MTU.
*/
u_long
uint32_t
tcp_maxmtu(struct in_conninfo *inc, struct tcp_ifcap *cap)
{
struct nhop4_extended nh4;
struct ifnet *ifp;
u_long maxmtu = 0;
uint32_t maxmtu = 0;
KASSERT(inc != NULL, ("tcp_maxmtu with NULL in_conninfo pointer"));
@ -2417,14 +2417,14 @@ tcp_maxmtu(struct in_conninfo *inc, struct tcp_ifcap *cap)
#endif /* INET */
#ifdef INET6
u_long
uint32_t
tcp_maxmtu6(struct in_conninfo *inc, struct tcp_ifcap *cap)
{
struct nhop6_extended nh6;
struct in6_addr dst6;
uint32_t scopeid;
struct ifnet *ifp;
u_long maxmtu = 0;
uint32_t maxmtu = 0;
KASSERT(inc != NULL, ("tcp_maxmtu6 with NULL in_conninfo pointer"));

View File

@ -1333,7 +1333,7 @@ tcp_fill_info(struct tcpcb *tp, struct tcp_info *ti)
ti->tcpi_options |= TCPI_OPT_ECN;
ti->tcpi_rto = tp->t_rxtcur * tick;
ti->tcpi_last_data_recv = (long)(ticks - (int)tp->t_rcvtime) * tick;
ti->tcpi_last_data_recv = ((uint32_t)ticks - tp->t_rcvtime) * tick;
ti->tcpi_rtt = ((u_int64_t)tp->t_srtt * tick) >> TCP_RTT_SHIFT;
ti->tcpi_rttvar = ((u_int64_t)tp->t_rttvar * tick) >> TCP_RTTVAR_SHIFT;
@ -2242,15 +2242,15 @@ db_print_tcpcb(struct tcpcb *tp, const char *name, int indent)
tp->iss, tp->irs, tp->rcv_nxt);
db_print_indent(indent);
db_printf("rcv_adv: 0x%08x rcv_wnd: %lu rcv_up: 0x%08x\n",
db_printf("rcv_adv: 0x%08x rcv_wnd: %u rcv_up: 0x%08x\n",
tp->rcv_adv, tp->rcv_wnd, tp->rcv_up);
db_print_indent(indent);
db_printf("snd_wnd: %lu snd_cwnd: %lu\n",
db_printf("snd_wnd: %u snd_cwnd: %u\n",
tp->snd_wnd, tp->snd_cwnd);
db_print_indent(indent);
db_printf("snd_ssthresh: %lu snd_recover: "
db_printf("snd_ssthresh: %u snd_recover: "
"0x%08x\n", tp->snd_ssthresh, tp->snd_recover);
db_print_indent(indent);
@ -2271,7 +2271,7 @@ db_print_tcpcb(struct tcpcb *tp, const char *name, int indent)
tp->t_rttbest);
db_print_indent(indent);
db_printf("t_rttupdated: %lu max_sndwnd: %lu t_softerror: %d\n",
db_printf("t_rttupdated: %lu max_sndwnd: %u t_softerror: %d\n",
tp->t_rttupdated, tp->max_sndwnd, tp->t_softerror);
db_print_indent(indent);
@ -2289,10 +2289,10 @@ db_print_tcpcb(struct tcpcb *tp, const char *name, int indent)
db_print_indent(indent);
db_printf("ts_offset: %u last_ack_sent: 0x%08x snd_cwnd_prev: "
"%lu\n", tp->ts_offset, tp->last_ack_sent, tp->snd_cwnd_prev);
"%u\n", tp->ts_offset, tp->last_ack_sent, tp->snd_cwnd_prev);
db_print_indent(indent);
db_printf("snd_ssthresh_prev: %lu snd_recover_prev: 0x%08x "
db_printf("snd_ssthresh_prev: %u snd_recover_prev: 0x%08x "
"t_badrxtwin: %u\n", tp->snd_ssthresh_prev,
tp->snd_recover_prev, tp->t_badrxtwin);

View File

@ -192,13 +192,13 @@ struct tcpcb {
tcp_seq rcv_nxt; /* receive next */
tcp_seq rcv_adv; /* advertised window */
u_long rcv_wnd; /* receive window */
uint32_t rcv_wnd; /* receive window */
tcp_seq rcv_up; /* receive urgent pointer */
u_long snd_wnd; /* send window */
u_long snd_cwnd; /* congestion-controlled window */
uint32_t snd_wnd; /* send window */
uint32_t snd_cwnd; /* congestion-controlled window */
u_long snd_spare1; /* unused */
u_long snd_ssthresh; /* snd_cwnd size threshold for
uint32_t snd_ssthresh; /* snd_cwnd size threshold for
* for slow start exponential to
* linear switch
*/
@ -223,7 +223,7 @@ struct tcpcb {
u_int t_rttmin; /* minimum rtt allowed */
u_int t_rttbest; /* best rtt we've seen */
u_long t_rttupdated; /* number of times rtt sampled */
u_long max_sndwnd; /* largest window peer has offered */
uint32_t max_sndwnd; /* largest window peer has offered */
int t_softerror; /* possible error not yet reported */
/* out-of-band data */
@ -239,8 +239,8 @@ struct tcpcb {
tcp_seq last_ack_sent;
/* experimental */
u_long snd_cwnd_prev; /* cwnd prior to retransmit */
u_long snd_ssthresh_prev; /* ssthresh prior to retransmit */
uint32_t snd_cwnd_prev; /* cwnd prior to retransmit */
uint32_t snd_ssthresh_prev; /* ssthresh prior to retransmit */
tcp_seq snd_recover_prev; /* snd_recover prior to retransmit */
int t_sndzerowin; /* zero-window updates sent */
u_int t_badrxtwin; /* window for retransmit recovery */
@ -415,13 +415,13 @@ struct tcpopt {
#define TO_SYN 0x01 /* parse SYN-only options */
struct hc_metrics_lite { /* must stay in sync with hc_metrics */
u_long rmx_mtu; /* MTU for this path */
u_long rmx_ssthresh; /* outbound gateway buffer limit */
u_long rmx_rtt; /* estimated round trip time */
u_long rmx_rttvar; /* estimated rtt variance */
u_long rmx_cwnd; /* congestion window */
u_long rmx_sendpipe; /* outbound delay-bandwidth product */
u_long rmx_recvpipe; /* inbound delay-bandwidth product */
uint32_t rmx_mtu; /* MTU for this path */
uint32_t rmx_ssthresh; /* outbound gateway buffer limit */
uint32_t rmx_rtt; /* estimated round trip time */
uint32_t rmx_rttvar; /* estimated rtt variance */
uint32_t rmx_cwnd; /* congestion window */
uint32_t rmx_sendpipe; /* outbound delay-bandwidth product */
uint32_t rmx_recvpipe; /* inbound delay-bandwidth product */
};
/*
@ -657,7 +657,7 @@ struct tcp_hhook_data {
struct tcpcb *tp;
struct tcphdr *th;
struct tcpopt *to;
long len;
uint32_t len;
int tso;
tcp_seq curack;
};
@ -802,8 +802,8 @@ struct tcp_function_block *find_and_ref_tcp_functions(struct tcp_function_set *f
struct tcp_function_block *find_and_ref_tcp_fb(struct tcp_function_block *blk);
int tcp_default_ctloutput(struct socket *so, struct sockopt *sopt, struct inpcb *inp, struct tcpcb *tp);
u_long tcp_maxmtu(struct in_conninfo *, struct tcp_ifcap *);
u_long tcp_maxmtu6(struct in_conninfo *, struct tcp_ifcap *);
uint32_t tcp_maxmtu(struct in_conninfo *, struct tcp_ifcap *);
uint32_t tcp_maxmtu6(struct in_conninfo *, struct tcp_ifcap *);
u_int tcp_maxseg(const struct tcpcb *);
void tcp_mss_update(struct tcpcb *, int, int, struct hc_metrics_lite *,
struct tcp_ifcap *);
@ -852,8 +852,8 @@ void tcp_hc_init(void);
void tcp_hc_destroy(void);
#endif
void tcp_hc_get(struct in_conninfo *, struct hc_metrics_lite *);
u_long tcp_hc_getmtu(struct in_conninfo *);
void tcp_hc_updatemtu(struct in_conninfo *, u_long);
uint32_t tcp_hc_getmtu(struct in_conninfo *);
void tcp_hc_updatemtu(struct in_conninfo *, uint32_t);
void tcp_hc_update(struct in_conninfo *, struct hc_metrics_lite *);
extern struct pr_usrreqs tcp_usrreqs;

View File

@ -417,12 +417,12 @@ tcp_trace(short act, short ostate, struct tcpcb *tp, int family __unused,
printf("\n");
if (sflag) {
printf("\trcv_nxt %lx rcv_wnd %lx snd_una %lx snd_nxt %lx snd_max %lx\n",
(u_long)tp->rcv_nxt, tp->rcv_wnd,
(u_long)tp->rcv_nxt, (u_long)tp->rcv_wnd,
(u_long)tp->snd_una, (u_long)tp->snd_nxt,
(u_long)tp->snd_max);
printf("\tsnd_wl1 %lx snd_wl2 %lx snd_wnd %lx\n",
(u_long)tp->snd_wl1,
(u_long)tp->snd_wl2, tp->snd_wnd);
(u_long)tp->snd_wl2, (u_long)tp->snd_wnd);
}
/* print out timers? */
#if 0