Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net/npf Fix an inverted logic.



details:   https://anonhg.NetBSD.org/src/rev/e2618e2f470d
branches:  trunk
changeset: 831590:e2618e2f470d
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sat Apr 07 09:20:25 2018 +0000

description:
Fix an inverted logic.

nbuf_cksum_barrier returns true when the direction is PFIL_OUT and TSO is
active; that is to say, it returns true when the checksum was already
recomputed by the function.

The check should be !nbuf_cksum_barrier, because otherwise we're wrongfully
checksumming twice, and it causes the packet to be kicked later in
tcp_input.

This can be seen with a configuration of the type:

        procedure "norm" {
                normalize: "max-mss" 15000
        }
        group default {
                pass all apply "norm"
        }

The packets systematically get dropped because the checksum validation in
tcp_input fails. With this patch in place, it works.

diffstat:

 sys/net/npf/npf_ext_normalize.c |  6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diffs (27 lines):

diff -r b525f18d0ea7 -r e2618e2f470d sys/net/npf/npf_ext_normalize.c
--- a/sys/net/npf/npf_ext_normalize.c   Sat Apr 07 09:06:26 2018 +0000
+++ b/sys/net/npf/npf_ext_normalize.c   Sat Apr 07 09:20:25 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: npf_ext_normalize.c,v 1.6 2017/12/10 00:07:36 rmind Exp $      */
+/*     $NetBSD: npf_ext_normalize.c,v 1.7 2018/04/07 09:20:25 maxv Exp $       */
 
 /*-
  * Copyright (c) 2009-2012 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #ifdef _KERNEL
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: npf_ext_normalize.c,v 1.6 2017/12/10 00:07:36 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: npf_ext_normalize.c,v 1.7 2018/04/07 09:20:25 maxv Exp $");
 
 #include <sys/types.h>
 #include <sys/module.h>
@@ -186,7 +186,7 @@
         * WARNING: must re-fetch the TCP header after the modification.
         */
        if (npf_fetch_tcpopts(npc, &maxmss, &wscale) &&
-           nbuf_cksum_barrier(npc->npc_nbuf, mi->mi_di)) {
+           !nbuf_cksum_barrier(npc->npc_nbuf, mi->mi_di)) {
                th = npc->npc_l4.tcp;
                cksum = npf_fixup16_cksum(th->th_sum, mss, maxmss);
                th->th_sum = cksum;



Home | Main Index | Thread Index | Old Index