From patchwork Fri Feb 17 18:16:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: stephen hemminger X-Patchwork-Id: 141977 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B62C7101190 for ; Sat, 18 Feb 2012 05:17:00 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752534Ab2BQSQ5 (ORCPT ); Fri, 17 Feb 2012 13:16:57 -0500 Received: from mail.vyatta.com ([76.74.103.46]:58972 "EHLO mail.vyatta.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751531Ab2BQSQ4 (ORCPT ); Fri, 17 Feb 2012 13:16:56 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.vyatta.com (Postfix) with ESMTP id A3CCD141000C; Fri, 17 Feb 2012 10:16:55 -0800 (PST) X-Virus-Scanned: amavisd-new at tahiti.vyatta.com Received: from mail.vyatta.com ([127.0.0.1]) by localhost (mail.vyatta.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xWpbgK6--SyE; Fri, 17 Feb 2012 10:16:49 -0800 (PST) Received: from nehalam.linuxnetplumber.net (static-50-53-80-93.bvtn.or.frontiernet.net [50.53.80.93]) by mail.vyatta.com (Postfix) with ESMTPSA id 7A9161410004; Fri, 17 Feb 2012 10:16:49 -0800 (PST) Date: Fri, 17 Feb 2012 10:16:48 -0800 From: Stephen Hemminger To: Eric Dumazet , Pablo Neira Ayuso , Patrick McHardy Cc: Konrad Rzeszutek Wilk , netdev@vger.kernel.org, davem@davemloft.net, netfilter-devel@vger.kernel.org Subject: [RFT] nf_contrack_udp: handle packets with padding and hwchecksum Message-ID: <20120217101648.01f31fcd@nehalam.linuxnetplumber.net> In-Reply-To: <1327944148.3303.1.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> References: <20120130155816.GA1400@phenom.dumpdata.com> <20120130083843.160ffe5e@nehalam.linuxnetplumber.net> <1327944148.3303.1.camel@edumazet-HP-Compaq-6005-Pro-SFF-PC> Organization: Vyatta X-Mailer: Claws Mail 3.8.0 (GTK+ 2.24.9; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org If UDP packet with extra padding is received on a device that does hardware checksumming (but not checking) is processed by netfilter conntrack, it would generate a bogus warning about the checksum being incorrect. There were two possible solutions. The netfilter conntrack code could trim the packet, discarding the extra padding and adjusting the checksum. Or it can force regular non-offloaded checksum. This patch implements the latter on the principal that is better for firewall code to not modify the packet. Compile tested only; haven't been able to reproduce the problem yet. Signed-off-by: Stephen Hemminger --- Patch against -net tree, after review/test it should go to stable as well. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/net/netfilter/nf_conntrack_proto_udp.c 2012-01-10 10:57:00.407196614 -0800 +++ b/net/netfilter/nf_conntrack_proto_udp.c 2012-02-17 10:06:18.038472559 -0800 @@ -125,12 +125,17 @@ static int udp_error(struct net *net, st * We skip checking packets on the outgoing path * because the checksum is assumed to be correct. * FIXME: Source route IP option packets --RR */ - if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING && - nf_checksum(skb, hooknum, dataoff, IPPROTO_UDP, pf)) { - if (LOG_INVALID(net, IPPROTO_UDP)) - nf_log_packet(pf, 0, skb, NULL, NULL, NULL, - "nf_ct_udp: bad UDP checksum "); - return -NF_ACCEPT; + if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING) { + /* Special case for hardware checksum offload with padding */ + if (skb->ip_summed == CHECKSUM_COMPLETE && udplen > ntohs(hdr->len)) + skb->ip_summed = CHECKSUM_NONE; + + if (nf_checksum(skb, hooknum, dataoff, IPPROTO_UDP, pf)) { + if (LOG_INVALID(net, IPPROTO_UDP)) + nf_log_packet(pf, 0, skb, NULL, NULL, NULL, + "nf_ct_udp: bad UDP checksum "); + return -NF_ACCEPT; + } } return NF_ACCEPT;