netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] net: l3mdev: Add master device lookup by index
@ 2015-11-19 20:32 David Ahern
  2015-11-19 20:32 ` [PATCH net-next 2/2] net: Add support for vrf-global TCP servers David Ahern
  2015-11-22 17:23 ` [PATCH net-next 1/2] net: l3mdev: Add master device lookup by index David Miller
  0 siblings, 2 replies; 10+ messages in thread
From: David Ahern @ 2015-11-19 20:32 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern

Add helper to lookup master index given a device index.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
 include/net/l3mdev.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/include/net/l3mdev.h b/include/net/l3mdev.h
index 774d85b2d5d9..786226f8e77b 100644
--- a/include/net/l3mdev.h
+++ b/include/net/l3mdev.h
@@ -51,6 +51,24 @@ static inline int l3mdev_master_ifindex(struct net_device *dev)
 	return ifindex;
 }
 
+static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)
+{
+	struct net_device *dev;
+	int rc = 0;
+
+	if (likely(ifindex)) {
+		rcu_read_lock();
+
+		dev = dev_get_by_index_rcu(net, ifindex);
+		if (dev)
+			rc = l3mdev_master_ifindex_rcu(dev);
+
+		rcu_read_unlock();
+	}
+
+	return rc;
+}
+
 /* get index of an interface to use for FIB lookups. For devices
  * enslaved to an L3 master device FIB lookups are based on the
  * master index
@@ -167,6 +185,11 @@ static inline int l3mdev_master_ifindex(struct net_device *dev)
 	return 0;
 }
 
+static inline int l3mdev_master_ifindex_by_index(struct net *net, int ifindex)
+{
+	return 0;
+}
+
 static inline int l3mdev_fib_oif_rcu(struct net_device *dev)
 {
 	return dev ? dev->ifindex : 0;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread
* [PATCH net-next v2 0/2] net: Allow accepted sockets to be bound to l3mdev domain
@ 2015-12-15 17:18 David Ahern
  2015-12-15 17:18 ` [PATCH net-next 1/2] net: l3mdev: Add master device lookup by index David Ahern
  0 siblings, 1 reply; 10+ messages in thread
From: David Ahern @ 2015-12-15 17:18 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern

Allow accepted sockets to derive their sk_bound_dev_if setting from the
l3mdev domain in which the packets originated. This version adds a sysctl
to control whether the setting is inherited, making the functionality
similar to sk_mark and its sysctl_tcp_fwmark_accept setting.

This effectively allow a process to have a "VRF-global" listen socket,
with child sockets bound to the VRF device in which the packet originated.
A similar behavior can be achieved using sk_mark, but a solution using marks
is incomplete as it does not handle duplicate addresses in different L3
domains/VRFs. Allowing sockets to inherit the sk_bound_dev_if from l3mdev
domain provides a complete solution.

v2
- Wrap the sk_bound_dev_if inheritance behavior in a new sysctl that
  defaults to disabled so a user has to opt-in

David Ahern (2):
  net: l3mdev: Add master device lookup by index
  net: Allow accepted sockets to be bound to l3mdev domain

 Documentation/networking/ip-sysctl.txt |  7 +++++++
 include/net/inet_sock.h                | 12 ++++++++++++
 include/net/l3mdev.h                   | 23 +++++++++++++++++++++++
 include/net/netns/ipv4.h               |  1 +
 net/ipv4/syncookies.c                  |  4 ++--
 net/ipv4/sysctl_net_ipv4.c             |  9 +++++++++
 net/ipv4/tcp_input.c                   |  2 +-
 net/ipv4/tcp_ipv4.c                    |  1 +
 net/ipv6/syncookies.c                  |  4 ++--
 9 files changed, 58 insertions(+), 5 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 10+ messages in thread
* [PATCH net-next v3 0/2] net: Allow accepted sockets to be bound to l3mdev domain
@ 2015-12-16 21:20 David Ahern
  2015-12-16 21:20 ` [PATCH net-next 1/2] net: l3mdev: Add master device lookup by index David Ahern
  0 siblings, 1 reply; 10+ messages in thread
From: David Ahern @ 2015-12-16 21:20 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern

Allow accepted sockets to derive their sk_bound_dev_if setting from the
l3mdev domain in which the packets originated. This version adds a sysctl
to control whether the setting is inherited, making the functionality
similar to sk_mark and its sysctl_tcp_fwmark_accept setting.

This effectively allow a process to have a "VRF-global" listen socket,
with child sockets bound to the VRF device in which the packet originated.
A similar behavior can be achieved using sk_mark, but a solution using marks
is incomplete as it does not handle duplicate addresses in different L3
domains/VRFs. Allowing sockets to inherit the sk_bound_dev_if from l3mdev
domain provides a complete solution.

David Ahern (2):
  net: l3mdev: Add master device lookup by index
  net: Allow accepted sockets to be bound to l3mdev domain

 Documentation/networking/ip-sysctl.txt |  8 ++++++++
 include/net/inet_sock.h                | 14 ++++++++++++++
 include/net/l3mdev.h                   | 23 +++++++++++++++++++++++
 include/net/netns/ipv4.h               |  3 +++
 net/ipv4/syncookies.c                  |  4 ++--
 net/ipv4/sysctl_net_ipv4.c             | 11 +++++++++++
 net/ipv4/tcp_input.c                   |  2 +-
 net/ipv4/tcp_ipv4.c                    |  1 +
 net/ipv6/syncookies.c                  |  4 ++--
 9 files changed, 65 insertions(+), 5 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-12-16 21:20 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-19 20:32 [PATCH net-next 1/2] net: l3mdev: Add master device lookup by index David Ahern
2015-11-19 20:32 ` [PATCH net-next 2/2] net: Add support for vrf-global TCP servers David Ahern
2015-11-22 17:23 ` [PATCH net-next 1/2] net: l3mdev: Add master device lookup by index David Miller
2015-11-22 17:30   ` David Ahern
2015-11-22 18:17     ` David Miller
2015-11-23  4:02       ` David Ahern
2015-11-23  4:35         ` David Miller
2015-11-23 18:28           ` David Ahern
  -- strict thread matches above, loose matches on Subject: below --
2015-12-15 17:18 [PATCH net-next v2 0/2] net: Allow accepted sockets to be bound to l3mdev domain David Ahern
2015-12-15 17:18 ` [PATCH net-next 1/2] net: l3mdev: Add master device lookup by index David Ahern
2015-12-16 21:20 [PATCH net-next v3 0/2] net: Allow accepted sockets to be bound to l3mdev domain David Ahern
2015-12-16 21:20 ` [PATCH net-next 1/2] net: l3mdev: Add master device lookup by index David Ahern

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).