From patchwork Sun Mar 29 01:38:30 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Harvey Harrison X-Patchwork-Id: 25262 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.176.167]) by ozlabs.org (Postfix) with ESMTP id B91B6DDE19 for ; Sun, 29 Mar 2009 12:38:41 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751795AbZC2Bii (ORCPT ); Sat, 28 Mar 2009 21:38:38 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1751668AbZC2Bih (ORCPT ); Sat, 28 Mar 2009 21:38:37 -0400 Received: from rv-out-0506.google.com ([209.85.198.233]:19924 "EHLO rv-out-0506.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750937AbZC2Big (ORCPT ); Sat, 28 Mar 2009 21:38:36 -0400 Received: by rv-out-0506.google.com with SMTP id f9so1877361rvb.1 for ; Sat, 28 Mar 2009 18:38:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:cc :content-type:date:message-id:mime-version:x-mailer :content-transfer-encoding; bh=nkRNyfnEEH5GCoYYobNr8+EAUFdyA9ADrT6T2Hav3i4=; b=Zz30sOx7xuy1I1Xo9W5sGUO4rtMUlUZv9rO9bOh3g8qc1k7SOhz6v1oMTTNEQ2i74Q D6EuKXfe41gBPaOten5o9bdM6M5uoBt4jsw3NkrT/j66NH52GEMAvPVK3nhRd8PFasvZ gUzbrdB8MKPPMLkLPWsVFNCb7xDULCnHTjLZw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:cc:content-type:date:message-id:mime-version :x-mailer:content-transfer-encoding; b=PxWEXJB/dCGWa/CS1VzoTMZywCd8/yzxEWkhTX7iGNLW5P4J+X5xI7tQ1RuR0JO63d DpTh09W+e94NvfDYl4ddV4TQyv83/+gITS7pNqenS6mciA2lOP877pMzeVS6HG2MTCAz 1yTplzxBbQ7miiX5JJyoYcwM6wRu9Crt3hVX0= Received: by 10.142.174.18 with SMTP id w18mr1537611wfe.24.1238290714605; Sat, 28 Mar 2009 18:38:34 -0700 (PDT) Received: from ?192.168.101.195? ([216.251.147.10]) by mx.google.com with ESMTPS id 29sm5934171wfg.33.2009.03.28.18.38.33 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 28 Mar 2009 18:38:34 -0700 (PDT) Subject: [PATCH 1/3] netfilter: fix endian bug in conntrack printks From: Harvey Harrison To: David Miller Cc: linux-netdev Date: Sat, 28 Mar 2009 18:38:30 -0700 Message-Id: <1238290710.3492.8.camel@brick> Mime-Version: 1.0 X-Mailer: Evolution 2.26.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org dcc_ip is treated as a host-endian value in the first printk, but the second printk uses %pI4 which expects a be32. This will cause a mismatch between the debug statement and the warning statement. Treat as a be32 throughout and avoid some byteswapping during some comparisions, and allow another user of HIPQUAD to bite the dust. Signed-off-by: Harvey Harrison --- Dave, this is probably suitable for 2.6.30 as a bugfix, I include the other removal patch only because it is the last user of HIPQUAD. net/netfilter/nf_conntrack_irc.c | 15 ++++++++------- 1 files changed, 8 insertions(+), 7 deletions(-) diff --git a/net/netfilter/nf_conntrack_irc.c b/net/netfilter/nf_conntrack_irc.c index 409c8be..c2e3c52 100644 --- a/net/netfilter/nf_conntrack_irc.c +++ b/net/netfilter/nf_conntrack_irc.c @@ -66,7 +66,7 @@ static const char *const dccprotos[] = { * ad_beg_p returns pointer to first byte of addr data * ad_end_p returns pointer to last byte of addr data */ -static int parse_dcc(char *data, const char *data_end, u_int32_t *ip, +static int parse_dcc(char *data, const char *data_end, __be32 *ip, u_int16_t *port, char **ad_beg_p, char **ad_end_p) { char *tmp; @@ -85,7 +85,7 @@ static int parse_dcc(char *data, const char *data_end, u_int32_t *ip, return -1; *ad_beg_p = data; - *ip = simple_strtoul(data, &data, 10); + *ip = cpu_to_be32(simple_strtoul(data, &data, 10)); /* skip blanks between ip and port */ while (*data == ' ') { @@ -112,7 +112,7 @@ static int help(struct sk_buff *skb, unsigned int protoff, int dir = CTINFO2DIR(ctinfo); struct nf_conntrack_expect *exp; struct nf_conntrack_tuple *tuple; - u_int32_t dcc_ip; + __be32 dcc_ip; u_int16_t dcc_port; __be16 port; int i, ret = NF_ACCEPT; @@ -177,13 +177,14 @@ static int help(struct sk_buff *skb, unsigned int protoff, pr_debug("unable to parse dcc command\n"); continue; } - pr_debug("DCC bound ip/port: %u.%u.%u.%u:%u\n", - HIPQUAD(dcc_ip), dcc_port); + + pr_debug("DCC bound ip/port: %pI4:%u\n", + &dcc_ip, dcc_port); /* dcc_ip can be the internal OR external (NAT'ed) IP */ tuple = &ct->tuplehash[dir].tuple; - if (tuple->src.u3.ip != htonl(dcc_ip) && - tuple->dst.u3.ip != htonl(dcc_ip)) { + if (tuple->src.u3.ip != dcc_ip && + tuple->dst.u3.ip != dcc_ip) { if (net_ratelimit()) printk(KERN_WARNING "Forged DCC command from %pI4: %pI4:%u\n",