Return-path: Received: from mail-pd0-f179.google.com ([209.85.192.179]:55961 "EHLO mail-pd0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755033AbaAFPSo (ORCPT ); Mon, 6 Jan 2014 10:18:44 -0500 Message-ID: <1389021522.12212.174.camel@edumazet-glaptop2.roam.corp.google.com> (sfid-20140106_161907_824127_DB2B6BB7) Subject: Re: [PATCH 4/11] use ether_addr_equal_64bits From: Eric Dumazet To: Geert Uytterhoeven Cc: Emmanuel Grumbach , Johannes Berg , Henrique de Moraes Holschuh , Julia Lawall , "kernel-janitors@vger.kernel.org" , Emmanuel Grumbach , Intel Linux Wireless , "John W. Linville" , linux-wireless , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" Date: Mon, 06 Jan 2014 07:18:42 -0800 In-Reply-To: References: <1388427307-8691-1-git-send-email-Julia.Lawall@lip6.fr> <1388427307-8691-5-git-send-email-Julia.Lawall@lip6.fr> <1388429761.4410.1.camel@jlt4.sipsolutions.net> <1388438724.4573.2.camel@jlt4.sipsolutions.net> <20131230215701.GA4938@khazad-dum.debian.net> <1388445188.18164.0.camel@jlt4.sipsolutions.net> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org List-ID: On Mon, 2014-01-06 at 10:24 +0100, Geert Uytterhoeven wrote: > Thanks to this discussion, my eye fell on: > > static inline unsigned compare_ether_addr(const u8 *addr1, const u8 *addr2) > { > const u16 *a = (const u16 *) addr1; > const u16 *b = (const u16 *) addr2; > > BUILD_BUG_ON(ETH_ALEN != 6); > return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2])) != 0; > } > > What if addr1 or addr2 are odd, and this is running on an architecture that > doesn't support unaligned accesses at all?? Have we been lucky forever? This function always had the guarantee of u16 alignment. No protocol ever included an ether address at an odd alignment, and drivers always make sure a frame is at least 2-byte aligned. Its kind of obvious for networking people, Stephen did not mention this property in commit 360ac8e2f1a38c34