All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: netdev@vger.kernel.org
Cc: idosch@idosch.org, davem@davemloft.net,
	roopa@cumulusnetworks.com, nikolay@cumulusnetworks.com,
	tom@herbertland.com, David Ahern <dsahern@gmail.com>
Subject: [PATCH v2 net-next 02/10] net: Align ip_multipath_l3_keys and ip6_multipath_l3_keys
Date: Thu,  1 Mar 2018 19:29:42 -0800	[thread overview]
Message-ID: <20180302032950.21154-3-dsahern@gmail.com> (raw)
In-Reply-To: <20180302032950.21154-1-dsahern@gmail.com>

Symmetry is good and allows easy comparison that ipv4 and ipv6 are
doing the same thing. To that end, change ip_multipath_l3_keys to
set addresses at the end after the icmp compares, and move the
initialization of ipv6 flow keys to rt6_multipath_hash.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 net/ipv4/route.c | 20 +++++++++++---------
 net/ipv6/route.c |  4 ++--
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 5615d26b3db7..78338f89370e 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1748,37 +1748,39 @@ static void ip_multipath_l3_keys(const struct sk_buff *skb,
 				 struct flow_keys *hash_keys)
 {
 	const struct iphdr *outer_iph = ip_hdr(skb);
+	const struct iphdr *key_iph = outer_iph;
 	const struct iphdr *inner_iph;
 	const struct icmphdr *icmph;
 	struct iphdr _inner_iph;
 	struct icmphdr _icmph;
 
-	hash_keys->addrs.v4addrs.src = outer_iph->saddr;
-	hash_keys->addrs.v4addrs.dst = outer_iph->daddr;
 	if (likely(outer_iph->protocol != IPPROTO_ICMP))
-		return;
+		goto out;
 
 	if (unlikely((outer_iph->frag_off & htons(IP_OFFSET)) != 0))
-		return;
+		goto out;
 
 	icmph = skb_header_pointer(skb, outer_iph->ihl * 4, sizeof(_icmph),
 				   &_icmph);
 	if (!icmph)
-		return;
+		goto out;
 
 	if (icmph->type != ICMP_DEST_UNREACH &&
 	    icmph->type != ICMP_REDIRECT &&
 	    icmph->type != ICMP_TIME_EXCEEDED &&
 	    icmph->type != ICMP_PARAMETERPROB)
-		return;
+		goto out;
 
 	inner_iph = skb_header_pointer(skb,
 				       outer_iph->ihl * 4 + sizeof(_icmph),
 				       sizeof(_inner_iph), &_inner_iph);
 	if (!inner_iph)
-		return;
-	hash_keys->addrs.v4addrs.src = inner_iph->saddr;
-	hash_keys->addrs.v4addrs.dst = inner_iph->daddr;
+		goto out;
+
+	key_iph = inner_iph;
+out:
+	hash_keys->addrs.v4addrs.src = key_iph->saddr;
+	hash_keys->addrs.v4addrs.dst = key_iph->daddr;
 }
 
 /* if skb is set it will be used and fl4 can be NULL */
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index e2bb40824c85..190d9690dfe0 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -1815,8 +1815,6 @@ static void ip6_multipath_l3_keys(const struct sk_buff *skb,
 	key_iph = inner_iph;
 	_flkeys = NULL;
 out:
-	memset(keys, 0, sizeof(*keys));
-	keys->control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
 	if (_flkeys) {
 		keys->addrs.v6addrs.src = _flkeys->addrs.v6addrs.src;
 		keys->addrs.v6addrs.dst = _flkeys->addrs.v6addrs.dst;
@@ -1837,6 +1835,8 @@ u32 rt6_multipath_hash(const struct flowi6 *fl6, const struct sk_buff *skb,
 	struct flow_keys hash_keys;
 
 	if (skb) {
+		memset(&hash_keys, 0, sizeof(hash_keys));
+		hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS;
 		ip6_multipath_l3_keys(skb, &hash_keys, flkeys);
 		return flow_hash_from_keys(&hash_keys) >> 1;
 	}
-- 
2.11.0

  parent reply	other threads:[~2018-03-02  3:30 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-02  3:29 [PATCH v2 net-next 00/10] net/ipv6: Add support for path selection using hash of 5-tuple David Ahern
2018-03-02  3:29 ` [PATCH v2 net-next 01/10] net/ipv4: Pass net to fib_multipath_hash instead of fib_info David Ahern
2018-03-02 13:12   ` Ido Schimmel
2018-03-02 15:28     ` David Ahern
2018-03-02  3:29 ` David Ahern [this message]
2018-03-02 13:22   ` [PATCH v2 net-next 02/10] net: Align ip_multipath_l3_keys and ip6_multipath_l3_keys Ido Schimmel
2018-03-02  3:29 ` [PATCH v2 net-next 03/10] net/ipv4: Simplify fib_multipath_hash with optional flow keys David Ahern
2018-03-02 13:26   ` Ido Schimmel
2018-03-02  3:29 ` [PATCH v2 net-next 04/10] net/ipv6: Make rt6_multipath_hash similar to fib_multipath_hash David Ahern
2018-03-02 13:35   ` Ido Schimmel
2018-03-02  3:29 ` [PATCH v2 net-next 05/10] net: Rename NETEVENT_MULTIPATH_HASH_UPDATE David Ahern
2018-03-02 13:36   ` Ido Schimmel
2018-03-02  3:29 ` [PATCH v2 net-next 06/10] net/ipv6: Pass skb to route lookup David Ahern
2018-03-02 13:49   ` Ido Schimmel
2018-03-02  3:29 ` [PATCH v2 net-next 07/10] net/ipv6: Add support for path selection using hash of 5-tuple David Ahern
2018-03-02 13:52   ` Ido Schimmel
2018-03-02  3:29 ` [PATCH v2 net-next 08/10] mlxsw: spectrum_router: Add support for ipv6 hash policy update David Ahern
2018-03-02 14:02   ` Ido Schimmel
2018-03-02 15:33     ` David Ahern
2018-03-02  3:29 ` [PATCH v2 net-next 09/10] net: Remove unused get_hash_from_flow functions David Ahern
2018-03-02 14:09   ` Ido Schimmel
2018-03-02 15:33     ` David Ahern
2018-03-02  3:29 ` [PATCH v2 net-next 10/10] selftests: forwarding: Add multipath test for L4 hashing David Ahern
2018-03-02 14:10   ` Ido Schimmel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180302032950.21154-3-dsahern@gmail.com \
    --to=dsahern@gmail.com \
    --cc=davem@davemloft.net \
    --cc=idosch@idosch.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=roopa@cumulusnetworks.com \
    --cc=tom@herbertland.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.