Thread (11 messages) 11 messages, 1 author, 2017-07-25
STALE3353d

Revision rfc of 2 in this series.

Revisions (2)
  1. rfc current
  2. v1 [diff vs current]

[RFC PATCH 08/10] net: Add sdif to sk_lookup

From: David Ahern <hidden>
Date: 2017-07-25 15:38:59
Subsystem: networking [general], networking [sockets], the rest · Maintainers: "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Kuniyuki Iwashima, Willem de Bruijn, Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help