Author: tuexen
Date: Tue Dec  4 22:05:36 2018
New Revision: 341497
URL: https://svnweb.freebsd.org/changeset/base/341497

Log:
  MFC r340738:
  
  Improve two KASSERTs in the TCP RACK stack.
  
  There are two locations where an always true comparison was made in
  a KASSERT. Replace this by an appropriate check and use a consistent
  panic message. Also use this code when checking a similar condition.
  
  PR:                   229664
  Reviewed by:          rrs@
  MFC after:            1 week
  Sponsored by:         Netflix, Inc.
  Differential Revision:        https://reviews.freebsd.org/D18021

Modified:
  stable/12/sys/netinet/tcp_stacks/rack.c
Directory Properties:
  stable/12/   (props changed)

Modified: stable/12/sys/netinet/tcp_stacks/rack.c
==============================================================================
--- stable/12/sys/netinet/tcp_stacks/rack.c     Tue Dec  4 21:57:26 2018        
(r341496)
+++ stable/12/sys/netinet/tcp_stacks/rack.c     Tue Dec  4 22:05:36 2018        
(r341497)
@@ -7053,12 +7053,10 @@ again:
                tlen = rsm->r_end - rsm->r_start;
                if (tlen > tp->t_maxseg)
                        tlen = tp->t_maxseg;
-#ifdef INVARIANTS
-               if (SEQ_GT(tp->snd_una, rsm->r_start)) {
-                       panic("tp:%p rack:%p snd_una:%u rsm:%p r_start:%u",
-                           tp, rack, tp->snd_una, rsm, rsm->r_start);
-               }
-#endif
+               KASSERT(SEQ_LEQ(tp->snd_una, rsm->r_start),
+                   ("%s:%d: r.start:%u < SND.UNA:%u; tp:%p, rack:%p, rsm:%p",
+                   __func__, __LINE__,
+                   rsm->r_start, tp->snd_una, tp, rack, rsm));
                sb_offset = rsm->r_start - tp->snd_una;
                cwin = min(tp->snd_wnd, tlen);
                len = cwin;
@@ -7069,12 +7067,14 @@ again:
                len = rsm->r_end - rsm->r_start;
                sack_rxmit = 1;
                sendalot = 0;
+               KASSERT(SEQ_LEQ(tp->snd_una, rsm->r_start),
+                   ("%s:%d: r.start:%u < SND.UNA:%u; tp:%p, rack:%p, rsm:%p",
+                   __func__, __LINE__,
+                   rsm->r_start, tp->snd_una, tp, rack, rsm));
                sb_offset = rsm->r_start - tp->snd_una;
                if (len >= tp->t_maxseg) {
                        len = tp->t_maxseg;
                }
-               KASSERT(sb_offset >= 0, ("%s: sack block to the left of una : 
%d",
-                   __func__, sb_offset));
        } else if ((rack->rc_in_persist == 0) &&
            ((rsm = tcp_rack_output(tp, rack, cts)) != NULL)) {
                long tlen;
@@ -7099,6 +7099,10 @@ again:
                }
 #endif
                tlen = rsm->r_end - rsm->r_start;
+               KASSERT(SEQ_LEQ(tp->snd_una, rsm->r_start),
+                   ("%s:%d: r.start:%u < SND.UNA:%u; tp:%p, rack:%p, rsm:%p",
+                   __func__, __LINE__,
+                   rsm->r_start, tp->snd_una, tp, rack, rsm));
                sb_offset = rsm->r_start - tp->snd_una;
                if (tlen > rack->r_ctl.rc_prr_sndcnt) {
                        len = rack->r_ctl.rc_prr_sndcnt;
@@ -7120,8 +7124,6 @@ again:
                                goto just_return_nolock;
                        }
                }
-               KASSERT(sb_offset >= 0, ("%s: sack block to the left of una : 
%d",
-                   __func__, sb_offset));
                if (len > 0) {
                        sub_from_prr = 1;
                        sack_rxmit = 1;
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to