From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89C02C2D0DB for ; Wed, 22 Jan 2020 09:38:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BCBA24680 for ; Wed, 22 Jan 2020 09:38:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579685937; bh=VDbWkC6uBBEeg/HWkCoBcE5qjljz8RrZQ0zWHQnLLnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Bytprxbma2Jilt7vEDcCef7/cHZIPFZSNw8Y3sldVEdkqOMx17Uy07vAughBSpQ48 BbAOsfVAZGh7cR4BRLgKklJv3NLdZ74pf6Z86X0xf6NJO6hsxU+X9XBolEBskZv4X4 bshf2rschMPxu27Em/MQxViE+SlkrKv5yQOdtX8M= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731934AbgAVJi4 (ORCPT ); Wed, 22 Jan 2020 04:38:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:55918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733111AbgAVJit (ORCPT ); Wed, 22 Jan 2020 04:38:49 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 839EC2467B; Wed, 22 Jan 2020 09:38:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579685929; bh=VDbWkC6uBBEeg/HWkCoBcE5qjljz8RrZQ0zWHQnLLnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=labauBqJBY8iP350DZdxpD0GGwGZArQ9ppCc++eR1gH/Q/za0wrH4Tp1eS2Cb/414 d1hjngQsY03SAOxMn/LiKlz4Pcpg8S5d3b6ADEV3uIXf3FUyXa0suEy/N9NXIl67rF u59PIuhxiXURXpKlePG3OFfU64P1GuwZhH0FImeQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sven Eckelmann , Simon Wunderlich Subject: [PATCH 4.14 40/65] batman-adv: Fix DAT candidate selection on little endian systems Date: Wed, 22 Jan 2020 10:29:25 +0100 Message-Id: <20200122092756.698323689@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092750.976732974@linuxfoundation.org> References: <20200122092750.976732974@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sven Eckelmann commit 4cc4a1708903f404d2ca0dfde30e71e052c6cbc9 upstream. The distributed arp table is using a DHT to store and retrieve MAC address information for an IP address. This is done using unicast messages to selected peers. The potential peers are looked up using the IP address and the VID. While the IP address is always stored in big endian byte order, this is not the case of the VID. It can (depending on the host system) either be big endian or little endian. The host must therefore always convert it to big endian to ensure that all devices calculate the same peers for the same lookup data. Fixes: be1db4f6615b ("batman-adv: make the Distributed ARP Table vlan aware") Signed-off-by: Sven Eckelmann Signed-off-by: Simon Wunderlich Signed-off-by: Greg Kroah-Hartman --- net/batman-adv/distributed-arp-table.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -243,6 +243,7 @@ static u32 batadv_hash_dat(const void *d u32 hash = 0; const struct batadv_dat_entry *dat = data; const unsigned char *key; + __be16 vid; u32 i; key = (const unsigned char *)&dat->ip; @@ -252,7 +253,8 @@ static u32 batadv_hash_dat(const void *d hash ^= (hash >> 6); } - key = (const unsigned char *)&dat->vid; + vid = htons(dat->vid); + key = (__force const unsigned char *)&vid; for (i = 0; i < sizeof(dat->vid); i++) { hash += key[i]; hash += (hash << 10);