MFC 1.33/pf.c from NetBSD. Don't apply a window scale to the window
authorMatthew Dillon <dillon@dragonflybsd.org>
Mon, 7 Apr 2008 00:43:44 +0000 (00:43 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Mon, 7 Apr 2008 00:43:44 +0000 (00:43 +0000)
size in a SYN packet.

Partial MFC 1.25/pf.c from NetBSD (specifically 1.487 from OpenBSD).
Fix a bug in the setting of sequence windows in the synproxy case.

sys/net/pf/pf.c

index e31decf..c935f87 100644 (file)
@@ -1,7 +1,7 @@
 /*     $FreeBSD: src/sys/contrib/pf/net/pf.c,v 1.19 2004/09/11 11:18:25 mlaier Exp $   */
 /*     $OpenBSD: pf.c,v 1.433.2.2 2004/07/17 03:22:34 brad Exp $ */
 /* add $OpenBSD: pf.c,v 1.448 2004/05/11 07:34:11 dhartmei Exp $ */
-/*     $DragonFly: src/sys/net/pf/pf.c,v 1.16 2008/04/06 21:12:41 dillon Exp $ */
+/*     $DragonFly: src/sys/net/pf/pf.c,v 1.17 2008/04/07 00:43:44 dillon Exp $ */
 
 /*
  * Copyright (c) 2004 The DragonFly Project.  All rights reserved.
@@ -2736,14 +2736,13 @@ cleanup:
                        rewrite = 1;
                } else
                        s->src.seqdiff = 0;
+               s->src.max_win = MAX(ntohs(th->th_win), 1);
                if (th->th_flags & TH_SYN) {
                        s->src.seqhi++;
                        s->src.wscale = pf_get_wscale(m, off, th->th_off, af);
-               }
-               s->src.max_win = MAX(ntohs(th->th_win), 1);
-               if (s->src.wscale & PF_WSCALE_MASK) {
+               } else if (s->src.wscale & PF_WSCALE_MASK) {
                        /* Remove scale factor from initial window */
-                       int win = s->src.max_win;
+                       u_int win = s->src.max_win;
                        win += 1 << (s->src.wscale & PF_WSCALE_MASK);
                        s->src.max_win = (win - 1) >>
                            (s->src.wscale & PF_WSCALE_MASK);
@@ -3781,9 +3780,9 @@ pf_test_state_tcp(struct pf_state **state, int direction, struct pfi_kif *kif,
                        (*state)->dst.seqdiff = (*state)->src.seqhi -
                            (*state)->dst.seqlo;
                        (*state)->src.seqhi = (*state)->src.seqlo +
-                           (*state)->src.max_win;
-                       (*state)->dst.seqhi = (*state)->dst.seqlo +
                            (*state)->dst.max_win;
+                       (*state)->dst.seqhi = (*state)->dst.seqlo +
+                           (*state)->src.max_win;
                        (*state)->src.wscale = (*state)->dst.wscale = 0;
                        (*state)->src.state = (*state)->dst.state =
                            TCPS_ESTABLISHED;