netdev.vger.kernel.org archive mirror
 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 03/10] net/ipv4: Simplify fib_multipath_hash with optional flow keys
Date: Thu,  1 Mar 2018 19:29:43 -0800	[thread overview]
Message-ID: <20180302032950.21154-4-dsahern@gmail.com> (raw)
In-Reply-To: <20180302032950.21154-1-dsahern@gmail.com>

As of commit e37b1e978bec5 ("ipv6: route: dissect flow in input path if
fib rules need it") fib_multipath_hash takes an optional flow keys. If
non-NULL it means the skb has already been dissected. If not set, then
fib_multipath_hash needs to call skb_flow_dissect_flow_keys.

Simplify the logic by setting flkeys to the local stack variable keys.
Simplifies fib_multipath_hash by only have 1 set of instructions
setting hash_keys.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 net/ipv4/route.c | 24 ++++++++++--------------
 1 file changed, 10 insertions(+), 14 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 78338f89370e..a7940b676f52 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1811,24 +1811,20 @@ int fib_multipath_hash(const struct net *net, const struct fib_info *fi,
 			/* short-circuit if we already have L4 hash present */
 			if (skb->l4_hash)
 				return skb_get_hash_raw(skb) >> 1;
+
 			memset(&hash_keys, 0, sizeof(hash_keys));
 
-			if (flkeys) {
-				hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
-				hash_keys.addrs.v4addrs.src = flkeys->addrs.v4addrs.src;
-				hash_keys.addrs.v4addrs.dst = flkeys->addrs.v4addrs.dst;
-				hash_keys.ports.src = flkeys->ports.src;
-				hash_keys.ports.dst = flkeys->ports.dst;
-				hash_keys.basic.ip_proto = flkeys->basic.ip_proto;
-			} else {
+			if (!flkeys) {
 				skb_flow_dissect_flow_keys(skb, &keys, flag);
-				hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
-				hash_keys.addrs.v4addrs.src = keys.addrs.v4addrs.src;
-				hash_keys.addrs.v4addrs.dst = keys.addrs.v4addrs.dst;
-				hash_keys.ports.src = keys.ports.src;
-				hash_keys.ports.dst = keys.ports.dst;
-				hash_keys.basic.ip_proto = keys.basic.ip_proto;
+				flkeys = &keys;
 			}
+
+			hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
+			hash_keys.addrs.v4addrs.src = flkeys->addrs.v4addrs.src;
+			hash_keys.addrs.v4addrs.dst = flkeys->addrs.v4addrs.dst;
+			hash_keys.ports.src = flkeys->ports.src;
+			hash_keys.ports.dst = flkeys->ports.dst;
+			hash_keys.basic.ip_proto = flkeys->basic.ip_proto;
 		} else {
 			memset(&hash_keys, 0, sizeof(hash_keys));
 			hash_keys.control.addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;
-- 
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 ` [PATCH v2 net-next 02/10] net: Align ip_multipath_l3_keys and ip6_multipath_l3_keys David Ahern
2018-03-02 13:22   ` Ido Schimmel
2018-03-02  3:29 ` David Ahern [this message]
2018-03-02 13:26   ` [PATCH v2 net-next 03/10] net/ipv4: Simplify fib_multipath_hash with optional flow keys 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-4-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).