Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp590456pxb; Thu, 14 Jan 2021 13:28:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzNNNpPdgA5bQ4bFE5Eq55QD0iXfVD0XeUe+3hvnMWmyK1qwoKUjhkyLvM0crvTYRQumyWV X-Received: by 2002:a17:906:52c1:: with SMTP id w1mr6707974ejn.214.1610659689743; Thu, 14 Jan 2021 13:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610659689; cv=none; d=google.com; s=arc-20160816; b=g6MhhJXGpjo9Zx0rP/Ax4OOyHhhsNVnyNHX3xUOwAHBNG6HB9zuX7/BrSpvIdX4Xos SxHUWTim9sQayJuS8KJw9ULTUti2BxnCL8DNZzZqK/1Kfivnse1BETZ+R41Lp3uT0nTZ +/Llzey7GqtnC6oRNSc+775QOT2vpLyvKkdFbCiII5TTGhceN8ul2EUnkM/Y3Ur9HAJK SU9Qg2IyMZ8EJj/6FBPEhIbX28FMorGyaO0alCwcgL38VCkDUXTP6JVtpTDPUE+V0KLz +B6zIKcfbzBigyfASuc6xS5NlkYfSAcKDe3Fz+RdrfEfkvzthPBddt9vbUYWZO9Yebz4 qx6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Xd3jefRz2Xj5lqAnS7NoMcAHkEKwZc71PSDjIwPZ6xw=; b=awJ2Lf9nAaCOrTj6eic4teHSz0nKbWnRPLohPDvD1qOQ5eSMfxhRWviIiZUi2pLeG5 /ido9sbwPEDOWE5TKud0bRVNl7pBDiiOInQ/rQ+2misacWSlCDe2X7s1hLhbIfyafCLL ueP/DypMjCyFmrulChbXNlLY+skRBOBOXZPSeBspawXZEw1exMtIDlWaAkdGHaMtPUHo PFiiznX+Fm/Ge4n5jxSU+pPahbU07xw8w2WGvgMXrx7RKXpGMqpj1CY1yF1d3EflCEXW NuBylkIzSCcL/91+WEX+c9Q7Y48s3AkLpwDyN+SfKR9nloYZ4A0OZ/8oTemLrc0uPkBn 9ikw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nyZv4R5E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si3412455edv.445.2021.01.14.13.27.46; Thu, 14 Jan 2021 13:28:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nyZv4R5E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728970AbhANVX5 (ORCPT + 99 others); Thu, 14 Jan 2021 16:23:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:47938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726123AbhANVX5 (ORCPT ); Thu, 14 Jan 2021 16:23:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D450622DFA; Thu, 14 Jan 2021 21:23:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1610659396; bh=J/aHoyoF4gk742GnjC+IHIsC05inBGzfoIzUewtb5eM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nyZv4R5EA0wzueGWWrToa/OKwIFT0kIhhX69EK0mBfnOnL1A/HOUKsfbZnWjQOr2I LEW89Re0OXmI/y7MPpVXLD16+fQaqvQ2dGi0wDws2ude3EIjJv8W+tbCFWllgtfNdR K/yDWga3yJpCa0s9bmB9OYd6lItvy48ONosMHuEMyy6r5Y1dTnztrcM5Kf23VQI0kN D+Svii8ujuZfLioTaVKYafCtvn/f1/GAOBoIxkIwUSjposhlaZrMh/R0lK8s9SqIGF LG0DyLhmss6MIoWEYWcyQyjNh1WbdZJvpEGLjwzdgPlGiXDYAMxdaT5TGlmqD/QjQw YM0Hrcm0FfYlw== Date: Thu, 14 Jan 2021 13:23:14 -0800 From: Jakub Kicinski To: Jarod Wilson Cc: linux-kernel@vger.kernel.org, Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Thomas Davis , netdev@vger.kernel.org Subject: Re: [PATCH net-next v2] bonding: add a vlan+mac tx hashing option Message-ID: <20210114132314.2c484e9f@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> In-Reply-To: <20210114211141.GH1171031@redhat.com> References: <20201218193033.6138-1-jarod@redhat.com> <20210113223548.1171655-1-jarod@redhat.com> <20210113175818.7dce3076@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20210114211141.GH1171031@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 14 Jan 2021 16:11:41 -0500 Jarod Wilson wrote: > In truth, this code started out as a copy of bond_eth_hash(), which also > only uses the last byte, though of both source and destination macs. In > the typical use case for the requesting user, the bond is formed from two > onboard NICs, which typically have adjacent mac addresses, i.e., > AA:BB:CC:DD:EE:01 and AA:BB:CC:DD:EE:02, so only the last byte is really > relevant to hash differently, but in thinking about it, a replacement NIC > because an onboard one died could have the same last byte, and maybe we > ought to just go full source mac right off the go here. > > Something like this instead maybe: > > static u32 bond_vlan_srcmac_hash(struct sk_buff *skb) > { > struct ethhdr *mac_hdr = (struct ethhdr *)skb_mac_header(skb); > u32 srcmac = 0; > u16 vlan; > int i; > > for (i = 0; i < ETH_ALEN; i++) > srcmac = (srcmac << 8) | mac_hdr->h_source[i]; > > if (!skb_vlan_tag_present(skb)) > return srcmac; > > vlan = skb_vlan_tag_get(skb); > > return vlan ^ srcmac; > } > > Then the documentation is spot-on, and we're future-proof, though > marginally less performant in calculating the hash, which may have been a > consideration when the original function was written, but is probably > basically irrelevant w/modern systems... No preference, especially if bond_eth_hash() already uses the last byte. Just make sure the choice is explained in the commit message.