From patchwork Thu Mar 28 07:50:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Antonio Quartulli X-Patchwork-Id: 2851 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=82.221.99.153; helo=diserzione.investici.org; envelope-from=ordex@autistici.org; receiver=b.a.t.m.a.n@lists.open-mesh.org Received: from diserzione.investici.org (diserzione.investici.org [82.221.99.153]) by open-mesh.org (Postfix) with ESMTPS id 25075601DB6 for ; Thu, 28 Mar 2013 08:52:06 +0100 (CET) Received: from [82.221.99.153] (diserzione [82.221.99.153]) (Authenticated sender: ordex@autistici.org) by localhost (Postfix) with ESMTPSA id 7285D180F21; Thu, 28 Mar 2013 07:52:04 +0000 (UTC) X-DKIM: Sendmail DKIM Filter v2.8.2 diserzione.investici.org 7285D180F21 From: Antonio Quartulli To: davem@davemloft.net Date: Thu, 28 Mar 2013 08:50:21 +0100 Message-Id: <1364457031-3194-2-git-send-email-ordex@autistici.org> X-Mailer: git-send-email 1.8.1.5 In-Reply-To: <1364457031-3194-1-git-send-email-ordex@autistici.org> References: <1364457031-3194-1-git-send-email-ordex@autistici.org> MIME-Version: 1.0 Cc: netdev@vger.kernel.org, =?UTF-8?q?Martin=20Hundeb=C3=B8ll?= , b.a.t.m.a.n@lists.open-mesh.org, Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 01/11] batman-adv: Fix endianness errors for network coding X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Mar 2013 07:52:06 -0000 From: Martin Hundebøll Add a htonl() in network_coding.c when reading the sequence number from received ogm_packet, to avoid wrong byte ordering when comparing with a host value. This bug was introduced in 3ed7ada3f0bbcd058567bc0a8f9729a73eba7db6 ("batman-adv: network coding - detect coding nodes and remove these after timeout"). Change the type of coded_packet->coded_len from uint16 to __be16 to avoid wrong assumptions about endianness in later uses. Introduced in c3289f3650d34b60296000a629c99f2488f7c3dd ("batman-adv: network coding - code and transmit packets if possible"). Reported-by: Fengguang Wu Signed-off-by: Martin Hundebøll Signed-off-by: Marek Lindner Signed-off-by: Antonio Quartulli --- net/batman-adv/network-coding.c | 2 +- net/batman-adv/packet.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index 5728079..086c107 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -654,7 +654,7 @@ static bool batadv_can_nc_with_orig(struct batadv_priv *bat_priv, struct batadv_orig_node *orig_node, struct batadv_ogm_packet *ogm_packet) { - if (orig_node->last_real_seqno != ogm_packet->seqno) + if (orig_node->last_real_seqno != ntohl(ogm_packet->seqno)) return false; if (orig_node->last_ttl != ogm_packet->header.ttl + 1) return false; diff --git a/net/batman-adv/packet.h b/net/batman-adv/packet.h index a079958..a51ccfc 100644 --- a/net/batman-adv/packet.h +++ b/net/batman-adv/packet.h @@ -308,7 +308,7 @@ struct batadv_coded_packet { uint8_t second_source[ETH_ALEN]; uint8_t second_orig_dest[ETH_ALEN]; __be32 second_crc; - uint16_t coded_len; + __be16 coded_len; }; #endif /* _NET_BATMAN_ADV_PACKET_H_ */