From patchwork Wed Aug 23 07:58:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 804873 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xcfv96yRzz9s9Y for ; Wed, 23 Aug 2017 17:58:45 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753546AbdHWH6n (ORCPT ); Wed, 23 Aug 2017 03:58:43 -0400 Received: from mail-wm0-f48.google.com ([74.125.82.48]:33535 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753541AbdHWH6m (ORCPT ); Wed, 23 Aug 2017 03:58:42 -0400 Received: by mail-wm0-f48.google.com with SMTP id b189so4662718wmd.0 for ; Wed, 23 Aug 2017 00:58:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mhvLMOTe5GTKzxoNGhp0JjfVzHAMY92ONfatJ7NAyOo=; b=AXVnB3jXH+Ixtr0lAcHNKbKdbzDhGodGQE/nIbDOoYdPBTggAv9ClVmXtX1SqQn4aN UAJLBDHPxFscL9clGBw9eMTZOT7hPe8pO0kALWi9wKNwvcAmBiLyDCbIJLgsDNkIxWlE xYPXDBGv1QxI7c+aa1TiG5vtIOoBTANK4LZcN0q0Z/BERE7B4OH5zVHT5eC1bz1AEMfH gjDpiDPdumoH5tHvHuTU2vi8Ntk2Hh2GUipZkEwQUiYi6GSNy5dCf+TLPIxcG3S47pfq cU5amkO+37jotyz8sV0inUERGEB3BznayjgOB+KMp5lwWmnSWMvfT0DOk4ZfXM3t/zv6 dL/A== X-Gm-Message-State: AHYfb5g5xSCptTpvnj2ibUfF6RYiWCQZhUayJGSp/JLivIK23o7JK+BL 6+J7KxavIc6CNbyv+lYBWg== X-Received: by 10.28.194.69 with SMTP id s66mr495674wmf.80.1503475120763; Wed, 23 Aug 2017 00:58:40 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id r79sm2317148wmd.42.2017.08.23.00.58.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Aug 2017 00:58:39 -0700 (PDT) From: Jakub Sitnicki To: netdev@vger.kernel.org Cc: "David S. Miller" , Hannes Frederic Sowa , Nikolay Aleksandrov , Tom Herbert Subject: [PATCH net-next v3 4/4] ipv6: Use multipath hash from flow info if available Date: Wed, 23 Aug 2017 09:58:31 +0200 Message-Id: <20170823075831.27031-5-jkbs@redhat.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170823075831.27031-1-jkbs@redhat.com> References: <20170823075831.27031-1-jkbs@redhat.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Allow our callers to influence the choice of ECMP link by honoring the hash passed together with the flow info. This allows for special treatment of ICMP errors which we would like to route over the same path as the IPv6 datagram that triggered the error. Also go through rt6_multipath_hash(), in the usual case when we aren't dealing with an ICMP error, so that there is one central place where multipath hash is computed. Signed-off-by: Jakub Sitnicki --- net/ipv6/route.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 246e7d7..4d02734 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c @@ -452,7 +452,13 @@ static struct rt6_info *rt6_multipath_select(struct rt6_info *match, struct rt6_info *sibling, *next_sibling; int route_choosen; - route_choosen = get_hash_from_flowi6(fl6) % (match->rt6i_nsiblings + 1); + /* We might have already computed the hash for ICMPv6 errors. In such + * case it will always be non-zero. Otherwise now is the time to do it. + */ + if (!fl6->mp_hash) + fl6->mp_hash = rt6_multipath_hash(fl6, NULL); + + route_choosen = fl6->mp_hash % (match->rt6i_nsiblings + 1); /* Don't change the route, if route_choosen == 0 * (siblings does not include ourself) */