View | Details | Raw Unified | Return to bug 148807
Collapse All | Expand All

(-)kern/uipc_sockbuf.c (-5 / +48 lines)
Lines 68-73 Link Here
68
static void	sbdrop_internal(struct sockbuf *sb, int len);
68
static void	sbdrop_internal(struct sockbuf *sb, int len);
69
static void	sbflush_internal(struct sockbuf *sb);
69
static void	sbflush_internal(struct sockbuf *sb);
70
70
71
#ifdef INVARIANTS
72
static int
73
sb_cc_check(struct sockbuf *sb)
74
{
75
	struct mbuf *n = sb->sb_mb;
76
	int slen = 0;
77
78
	while (n) {
79
		slen = m_length(n, &n);
80
		n = n->m_nextpkt;
81
	}
82
83
	return (slen == sb->sb_cc ? 1 : 0);
84
}
85
#endif
86
71
/*
87
/*
72
 * Socantsendmore indicates that no more data will be sent on the socket; it
88
 * Socantsendmore indicates that no more data will be sent on the socket; it
73
 * would normally be applied to a socket when the user informs the system
89
 * would normally be applied to a socket when the user informs the system
Lines 528-533 Link Here
528
544
529
	SBLASTMBUFCHK(sb);
545
	SBLASTMBUFCHK(sb);
530
546
547
	KASSERT(sb_cc_check(sb),
548
	    ("%s: sb_cc != total mbuf length - before", __func__));
549
531
	/* Remove all packet headers and mbuf tags to get a pure data chain. */
550
	/* Remove all packet headers and mbuf tags to get a pure data chain. */
532
	m_demote(m, 1);
551
	m_demote(m, 1);
533
	
552
	
Lines 535-540 Link Here
535
554
536
	sb->sb_lastrecord = sb->sb_mb;
555
	sb->sb_lastrecord = sb->sb_mb;
537
	SBLASTRECORDCHK(sb);
556
	SBLASTRECORDCHK(sb);
557
558
	KASSERT(sb_cc_check(sb),
559
	    ("%s: sb_cc != total mbuf length - after", __func__));
538
}
560
}
539
561
540
/*
562
/*
Lines 811-816 Link Here
811
sbflush_internal(struct sockbuf *sb)
833
sbflush_internal(struct sockbuf *sb)
812
{
834
{
813
835
836
	KASSERT(sb_cc_check(sb),
837
	    ("%s: sb_cc != total mbuf length", __func__));
838
814
	while (sb->sb_mbcnt) {
839
	while (sb->sb_mbcnt) {
815
		/*
840
		/*
816
		 * Don't call sbdrop(sb, 0) if the leading mbuf is non-empty:
841
		 * Don't call sbdrop(sb, 0) if the leading mbuf is non-empty:
Lines 851-860 Link Here
851
	struct mbuf *m;
876
	struct mbuf *m;
852
	struct mbuf *next;
877
	struct mbuf *next;
853
878
854
	next = (m = sb->sb_mb) ? m->m_nextpkt : 0;
879
	KASSERT(len <= sb->sb_cc,
880
	    ("%s: len > sb->sb_cc", __func__));
881
	KASSERT(sb->sb_cc >= sb->sb_sndptroff,
882
	    ("%s: sb_sndptroff > sb_cc", __func__));
883
	KASSERT(sb_cc_check(sb),
884
	    ("%s: sb_cc != total mbuf length - enter", __func__));
885
886
	if (len > sb->sb_sndptroff) {
887
		sb->sb_sndptroff = 0;
888
		sb->sb_sndptr = NULL;
889
	}
890
891
	next = (m = sb->sb_mb) ? m->m_nextpkt : NULL;
855
	while (len > 0) {
892
	while (len > 0) {
856
		if (m == 0) {
893
		if (m == NULL) {
857
			if (next == 0)
894
			if (next == NULL)
858
				panic("sbdrop");
895
				panic("sbdrop");
859
			m = next;
896
			m = next;
860
			next = m->m_nextpkt;
897
			next = m->m_nextpkt;
Lines 874-880 Link Here
874
		sbfree(sb, m);
911
		sbfree(sb, m);
875
		m = m_free(m);
912
		m = m_free(m);
876
	}
913
	}
877
	while (m && m->m_len == 0) {
914
	while (m != NULL && m->m_len == 0) {
878
		sbfree(sb, m);
915
		sbfree(sb, m);
879
		m = m_free(m);
916
		m = m_free(m);
880
	}
917
	}
Lines 891-899 Link Here
891
	if (m == NULL) {
928
	if (m == NULL) {
892
		sb->sb_mbtail = NULL;
929
		sb->sb_mbtail = NULL;
893
		sb->sb_lastrecord = NULL;
930
		sb->sb_lastrecord = NULL;
931
		sb->sb_sndptr = NULL;
894
	} else if (m->m_nextpkt == NULL) {
932
	} else if (m->m_nextpkt == NULL) {
895
		sb->sb_lastrecord = m;
933
		sb->sb_lastrecord = m;
896
	}
934
	}
935
936
	KASSERT(sb_cc_check(sb),
937
	    ("%s: sb_cc != total mbuf length - exit", __func__));
897
}
938
}
898
939
899
/*
940
/*
Lines 922-934 Link Here
922
 * avoid traversal of the entire socket buffer for larger offsets.
963
 * avoid traversal of the entire socket buffer for larger offsets.
923
 */
964
 */
924
struct mbuf *
965
struct mbuf *
925
sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff)
966
sbsndptr(struct sockbuf *sb, int off, int len, int *moff)
926
{
967
{
927
	struct mbuf *m, *ret;
968
	struct mbuf *m, *ret;
928
969
929
	KASSERT(sb->sb_mb != NULL, ("%s: sb_mb is NULL", __func__));
970
	KASSERT(sb->sb_mb != NULL, ("%s: sb_mb is NULL", __func__));
930
	KASSERT(off + len <= sb->sb_cc, ("%s: beyond sb", __func__));
971
	KASSERT(off + len <= sb->sb_cc, ("%s: beyond sb", __func__));
931
	KASSERT(sb->sb_sndptroff <= sb->sb_cc, ("%s: sndptroff broken", __func__));
972
	KASSERT(sb->sb_sndptroff <= sb->sb_cc, ("%s: sndptroff broken", __func__));
973
	KASSERT(sb_cc_check(sb),
974
	    ("%s: sb_cc != total mbuf length", __func__));
932
975
933
	/*
976
	/*
934
	 * Is off below stored offset? Happens on retransmits.
977
	 * Is off below stored offset? Happens on retransmits.
(-)sys/sockbuf.h (-1 / +1 lines)
Lines 152-158 Link Here
152
int	sbreserve_locked(struct sockbuf *sb, u_long cc, struct socket *so,
152
int	sbreserve_locked(struct sockbuf *sb, u_long cc, struct socket *so,
153
	    struct thread *td);
153
	    struct thread *td);
154
struct mbuf *
154
struct mbuf *
155
	sbsndptr(struct sockbuf *sb, u_int off, u_int len, u_int *moff);
155
	sbsndptr(struct sockbuf *sb, int off, int len, int *moff);
156
void	sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
156
void	sbtoxsockbuf(struct sockbuf *sb, struct xsockbuf *xsb);
157
int	sbwait(struct sockbuf *sb);
157
int	sbwait(struct sockbuf *sb);
158
int	sblock(struct sockbuf *sb, int flags);
158
int	sblock(struct sockbuf *sb, int flags);
(-)netinet/tcp_output.c (-3 / +4 lines)
Lines 153-159 Link Here
153
	int idle, sendalot;
153
	int idle, sendalot;
154
	int sack_rxmit, sack_bytes_rxmt;
154
	int sack_rxmit, sack_bytes_rxmt;
155
	struct sackhole *p;
155
	struct sackhole *p;
156
	int tso = 0;
156
	int tso;
157
	struct tcpopt to;
157
	struct tcpopt to;
158
#if 0
158
#if 0
159
	int maxburst = TCP_MAXBURST;
159
	int maxburst = TCP_MAXBURST;
Lines 211-216 Link Here
211
	    SEQ_LT(tp->snd_nxt, tp->snd_max))
211
	    SEQ_LT(tp->snd_nxt, tp->snd_max))
212
		tcp_sack_adjust(tp);
212
		tcp_sack_adjust(tp);
213
	sendalot = 0;
213
	sendalot = 0;
214
	tso = 0;
214
	off = tp->snd_nxt - tp->snd_una;
215
	off = tp->snd_nxt - tp->snd_una;
215
	sendwin = min(tp->snd_wnd, tp->snd_cwnd);
216
	sendwin = min(tp->snd_wnd, tp->snd_cwnd);
216
	sendwin = min(sendwin, tp->snd_bwnd);
217
	sendwin = min(sendwin, tp->snd_bwnd);
Lines 490-498 Link Here
490
		} else {
491
		} else {
491
			len = tp->t_maxseg;
492
			len = tp->t_maxseg;
492
			sendalot = 1;
493
			sendalot = 1;
493
			tso = 0;
494
		}
494
		}
495
	}
495
	}
496
496
	if (sack_rxmit) {
497
	if (sack_rxmit) {
497
		if (SEQ_LT(p->rxmit + len, tp->snd_una + so->so_snd.sb_cc))
498
		if (SEQ_LT(p->rxmit + len, tp->snd_una + so->so_snd.sb_cc))
498
			flags &= ~TH_FIN;
499
			flags &= ~TH_FIN;
Lines 766-772 Link Here
766
	 */
794
	 */
767
	if (len) {
795
	if (len) {
768
		struct mbuf *mb;
796
		struct mbuf *mb;
769
		u_int moff;
797
		int moff;
770
798
771
		if ((tp->t_flags & TF_FORCEDATA) && len == 1)
799
		if ((tp->t_flags & TF_FORCEDATA) && len == 1)
772
			TCPSTAT_INC(tcps_sndprobe);
800
			TCPSTAT_INC(tcps_sndprobe);

Return to bug 148807