netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: netdev@vger.kernel.org
Cc: David Ahern <dsahern@gmail.com>
Subject: [PATCH net-next 08/10] net: Add sdif to sk_lookup
Date: Mon, 31 Jul 2017 20:13:24 -0700	[thread overview]
Message-ID: <1501557206-27503-9-git-send-email-dsahern@gmail.com> (raw)
In-Reply-To: <1501557206-27503-1-git-send-email-dsahern@gmail.com>

Add a second device index, sdif, to the socket lookup struct. sdif
will be the device index for devices enslaved to an l3mdev. It allows
the lookups to consider the enslaved device as well as the L3 master
device when searching for a socket.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 include/net/sock.h | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index a2db5fd30192..c5d93a4bcd0a 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -507,23 +507,27 @@ struct sk_lookup {
 	unsigned short hnum;
 
 	int dif;
+	int sdif;
 	bool exact_dif;
 };
 
-/* Compare sk_bound_dev_if to socket lookup dif
+/* Compare sk_bound_dev_if to socket lookup dif and sdif
  * Returns:
  *   -1   exact dif required and not met
  *    0   sk_bound_dev_if is either not set or does not match
- *    1   sk_bound_dev_if is set and matches dif
+ *    1   sk_bound_dev_if is set and matches dif or sdif
  */
 static inline int sk_lookup_device_cmp(const struct sock *sk,
 				       const struct sk_lookup *params)
 {
+	bool dev_match = (sk->sk_bound_dev_if == params->dif ||
+			  sk->sk_bound_dev_if == params->sdif);
+
 	/* exact_dif true == l3mdev case */
-	if (params->exact_dif && sk->sk_bound_dev_if != params->dif)
+	if (params->exact_dif && !dev_match)
 		return -1;
 
-	if (sk->sk_bound_dev_if && sk->sk_bound_dev_if == params->dif)
+	if (sk->sk_bound_dev_if && dev_match)
 		return 1;
 
 	return 0;
-- 
2.1.4

  parent reply	other threads:[~2017-08-01  3:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-01  3:13 [PATCH net-next 00/10] net: l3mdev: Support for sockets bound to enslaved device David Ahern
2017-08-01  3:13 ` [PATCH net-next 01/10] net: Add sk_lookup struct and helper David Ahern
2017-08-01  3:13 ` [PATCH net-next 02/10] net: ipv4: Convert udp socket lookups to new struct David Ahern
2017-08-01  3:13 ` [PATCH net-next 03/10] net: ipv4: Convert inet " David Ahern
2017-08-01  3:13 ` [PATCH net-next 04/10] net: ipv4: Convert raw sockets to sk_lookup David Ahern
2017-08-01  3:13 ` [PATCH net-next 05/10] net: ipv6: Convert udp socket lookups to new struct David Ahern
2017-08-01  3:13 ` [PATCH net-next 06/10] net: ipv6: Convert inet " David Ahern
2017-08-01  3:13 ` [PATCH net-next 07/10] net: ipv6: Convert raw sockets to sk_lookup David Ahern
2017-08-01  3:13 ` David Ahern [this message]
2017-08-01  3:13 ` [PATCH net-next 09/10] net: ipv4: Support for sockets bound to enslaved device David Ahern
2017-08-01  3:13 ` [PATCH net-next 10/10] net: ipv6: " David Ahern
2017-08-01 14:15 ` [PATCH net-next 00/10] net: l3mdev: " David Laight
2017-08-01 14:45   ` David Ahern
2017-08-02  0:41 ` David Miller
2017-08-04 20:17   ` David Ahern

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=1501557206-27503-9-git-send-email-dsahern@gmail.com \
    --to=dsahern@gmail.com \
    --cc=netdev@vger.kernel.org \
    /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).