Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4628694ybl; Wed, 22 Jan 2020 01:34:48 -0800 (PST) X-Google-Smtp-Source: APXvYqyThE/ZnOfdTK3LYqE2RybTgq5mfQIMivnCQ+ic2G4E+6FqP5lywkwVKsb/G5AYf0mxw0sX X-Received: by 2002:a05:6830:15ca:: with SMTP id j10mr6897659otr.190.1579685688291; Wed, 22 Jan 2020 01:34:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579685688; cv=none; d=google.com; s=arc-20160816; b=WcWaoiw7FOx78V48YuZAW6paSs5vrGJKEVUSIaKnb2cdpGc+xoTHVJ6xnDpug3mHdH FkrTtsecJCoY/Hn95YtNmLJND/VNQHg8Wlv10NCRiJQrE3/7Z4ecMFrEIv1AHPQkGQgL fQyoGlNUHGxlZ7AKxCv3XGG99iH3JXkvXQcr7Y/HBLbwfI0wyZuUv5zH7D9aCj8wwGkQ o3fqhY/+sGOTDuroS84bYadxs2DqDAeNeo26Py63ebKrfoEzZ9v+b0qV2v87PvxHtmEL flP/a2r776EH9NdtIB/t4/AIJ5c82Fklc4anNZq0GeZ8gUDKMb1a4bOVSaPOMtEECwCk w2tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=L9L4vkQdnsuvf7rYRUt3bSdbNSVNNxlrug1WrkoI4ZA=; b=Vxo0kpDV/SrcHSXB26dZNVeVGxbIl/JQhTsJGMOuJbTH/L6/jOfW0Adrb9l0316AqV aCxLpgd+AsOpFRs+ebD6erGyhGIslIzo11rZqVZ+tinHp4fYBdD6PaleGJUm0M6cBWQm a+T6XxZvRfzVusQ1qSav//rbf4IaTm/K8ilPdd6jyCiJdwNigQjInHNZCQ4WVqmYrHxV 2hWFwdiQywog306Q83wj+tU0xLvT4PQcp+NH7eANXgsipGIIb1QBJ6MLSnGuVlhmT7nc 3bQyjKiYof6sLz1xxHChoD/Eev9atiazZH5w3rjpx2ge7GzRLVkGjkM3mwKjY9UmqSzt ywyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rDVii5Bu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p16si21086034oto.287.2020.01.22.01.34.36; Wed, 22 Jan 2020 01:34:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rDVii5Bu; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730202AbgAVJcn (ORCPT + 99 others); Wed, 22 Jan 2020 04:32:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:45712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730191AbgAVJck (ORCPT ); Wed, 22 Jan 2020 04:32:40 -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 71A8524672; Wed, 22 Jan 2020 09:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579685559; bh=zxjU3nRueOaA8zHNv+fdsdNJlX+bgYX1ARuDDrQAeGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rDVii5BuKp9EIcn2zMUnuP9qv0Ha1YCkz4MeRZ2h7yMB/2Q1eu2BH5cP/zcRkgPP+ dFqqq9Uf47WwkQXmZUZx8fDxNloENDpjIHmtZgYX77agslapDSbipX54hGO1XfwnRT NT4Lsqb8OyyvPySJhBsYEhexCFMzE+idh1xlM6rA= 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.4 62/76] batman-adv: Fix DAT candidate selection on little endian systems Date: Wed, 22 Jan 2020 10:29:18 +0100 Message-Id: <20200122092800.573851864@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200122092751.587775548@linuxfoundation.org> References: <20200122092751.587775548@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 @@ -226,6 +226,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; @@ -235,7 +236,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);