netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/4] inet: make RTM_GETROUTE work without rtnl
@ 2017-08-15 14:34 Florian Westphal
  2017-08-15 14:34 ` [PATCH net-next 1/4] selftests: add 'ip get' to rtnetlink.sh Florian Westphal
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Florian Westphal @ 2017-08-15 14:34 UTC (permalink / raw)
  To: netdev

ipv4 getroute doesn't assume rtnl lock is held anymore, also make
this true for ipv6, then switch both to DOIT_UNLOCKED.

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

* [PATCH net-next 1/4] selftests: add 'ip get' to rtnetlink.sh
  2017-08-15 14:34 [PATCH net-next 0/4] inet: make RTM_GETROUTE work without rtnl Florian Westphal
@ 2017-08-15 14:34 ` Florian Westphal
  2017-08-15 14:34 ` [PATCH net-next 2/4] ipv6: route: make rtm_getroute not assume rtnl is locked Florian Westphal
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Westphal @ 2017-08-15 14:34 UTC (permalink / raw)
  To: netdev; +Cc: Florian Westphal

exercise ip/ip6 RTM_GETROUTE doit() callpath.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 tools/testing/selftests/net/rtnetlink.sh | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/tools/testing/selftests/net/rtnetlink.sh b/tools/testing/selftests/net/rtnetlink.sh
index 5b04ad912525..84b4acf5baa9 100755
--- a/tools/testing/selftests/net/rtnetlink.sh
+++ b/tools/testing/selftests/net/rtnetlink.sh
@@ -164,6 +164,37 @@ kci_test_polrouting()
 	echo "PASS: policy routing"
 }
 
+kci_test_route_get()
+{
+	ret=0
+
+	ip route get 127.0.0.1 > /dev/null
+	check_err $?
+	ip route get 127.0.0.1 dev "$devdummy" > /dev/null
+	check_err $?
+	ip route get ::1 > /dev/null
+	check_err $?
+	ip route get fe80::1 dev "$devdummy" > /dev/null
+	check_err $?
+	ip route get 127.0.0.1 from 127.0.0.1 oif lo tos 0x1 mark 0x1 > /dev/null
+	check_err $?
+	ip route get ::1 from ::1 iif lo oif lo tos 0x1 mark 0x1 > /dev/null
+	check_err $?
+	ip addr add dev "$devdummy" 10.23.7.11/24
+	check_err $?
+	ip route get 10.23.7.11 from 10.23.7.12 iif "$devdummy" > /dev/null
+	check_err $?
+	ip addr del dev "$devdummy" 10.23.7.11/24
+	check_err $?
+
+	if [ $ret -ne 0 ];then
+		echo "FAIL: route get"
+		return 1
+	fi
+
+	echo "PASS: route get"
+}
+
 kci_test_rtnl()
 {
 	kci_add_dummy
@@ -173,6 +204,7 @@ kci_test_rtnl()
 	fi
 
 	kci_test_polrouting
+	kci_test_route_get
 	kci_test_tc
 	kci_test_gre
 	kci_test_bridge
-- 
2.13.0

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

* [PATCH net-next 2/4] ipv6: route: make rtm_getroute not assume rtnl is locked
  2017-08-15 14:34 [PATCH net-next 0/4] inet: make RTM_GETROUTE work without rtnl Florian Westphal
  2017-08-15 14:34 ` [PATCH net-next 1/4] selftests: add 'ip get' to rtnetlink.sh Florian Westphal
@ 2017-08-15 14:34 ` Florian Westphal
  2017-08-15 14:34 ` [PATCH net-next 3/4] ipv6: route: set ipv6 RTM_GETROUTE to not use rtnl Florian Westphal
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Westphal @ 2017-08-15 14:34 UTC (permalink / raw)
  To: netdev; +Cc: Florian Westphal

__dev_get_by_index assumes RTNL is held, use _rcu version instead.

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 net/ipv6/route.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index 035762fed07d..ec694fdb8cc5 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -3616,8 +3616,11 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 		struct net_device *dev;
 		int flags = 0;
 
-		dev = __dev_get_by_index(net, iif);
+		rcu_read_lock();
+
+		dev = dev_get_by_index_rcu(net, iif);
 		if (!dev) {
+			rcu_read_unlock();
 			err = -ENODEV;
 			goto errout;
 		}
@@ -3629,6 +3632,8 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 
 		if (!fibmatch)
 			dst = ip6_route_input_lookup(net, dev, &fl6, flags);
+
+		rcu_read_unlock();
 	} else {
 		fl6.flowi6_oif = oif;
 
-- 
2.13.0

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

* [PATCH net-next 3/4] ipv6: route: set ipv6 RTM_GETROUTE to not use rtnl
  2017-08-15 14:34 [PATCH net-next 0/4] inet: make RTM_GETROUTE work without rtnl Florian Westphal
  2017-08-15 14:34 ` [PATCH net-next 1/4] selftests: add 'ip get' to rtnetlink.sh Florian Westphal
  2017-08-15 14:34 ` [PATCH net-next 2/4] ipv6: route: make rtm_getroute not assume rtnl is locked Florian Westphal
@ 2017-08-15 14:34 ` Florian Westphal
  2017-08-15 14:34 ` [PATCH net-next 4/4] ipv4: route: set ipv4 " Florian Westphal
  2017-08-16  0:21 ` [PATCH net-next 0/4] inet: make RTM_GETROUTE work without rtnl David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Westphal @ 2017-08-15 14:34 UTC (permalink / raw)
  To: netdev; +Cc: Florian Westphal

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 net/ipv6/route.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index ec694fdb8cc5..3c15f005c90e 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -4112,7 +4112,8 @@ int __init ip6_route_init(void)
 	ret = -ENOBUFS;
 	if (__rtnl_register(PF_INET6, RTM_NEWROUTE, inet6_rtm_newroute, NULL, 0) ||
 	    __rtnl_register(PF_INET6, RTM_DELROUTE, inet6_rtm_delroute, NULL, 0) ||
-	    __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL, 0))
+	    __rtnl_register(PF_INET6, RTM_GETROUTE, inet6_rtm_getroute, NULL,
+			    RTNL_FLAG_DOIT_UNLOCKED))
 		goto out_register_late_subsys;
 
 	ret = register_netdevice_notifier(&ip6_route_dev_notifier);
-- 
2.13.0

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

* [PATCH net-next 4/4] ipv4: route: set ipv4 RTM_GETROUTE to not use rtnl
  2017-08-15 14:34 [PATCH net-next 0/4] inet: make RTM_GETROUTE work without rtnl Florian Westphal
                   ` (2 preceding siblings ...)
  2017-08-15 14:34 ` [PATCH net-next 3/4] ipv6: route: set ipv6 RTM_GETROUTE to not use rtnl Florian Westphal
@ 2017-08-15 14:34 ` Florian Westphal
  2017-08-16  0:21 ` [PATCH net-next 0/4] inet: make RTM_GETROUTE work without rtnl David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Florian Westphal @ 2017-08-15 14:34 UTC (permalink / raw)
  To: netdev; +Cc: Florian Westphal

Signed-off-by: Florian Westphal <fw@strlen.de>
---
 net/ipv4/route.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 6810d2076b1b..618bbe1405fc 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -3073,7 +3073,8 @@ int __init ip_rt_init(void)
 	xfrm_init();
 	xfrm4_init();
 #endif
-	rtnl_register(PF_INET, RTM_GETROUTE, inet_rtm_getroute, NULL, 0);
+	rtnl_register(PF_INET, RTM_GETROUTE, inet_rtm_getroute, NULL,
+		      RTNL_FLAG_DOIT_UNLOCKED);
 
 #ifdef CONFIG_SYSCTL
 	register_pernet_subsys(&sysctl_route_ops);
-- 
2.13.0

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

* Re: [PATCH net-next 0/4] inet: make RTM_GETROUTE work without rtnl
  2017-08-15 14:34 [PATCH net-next 0/4] inet: make RTM_GETROUTE work without rtnl Florian Westphal
                   ` (3 preceding siblings ...)
  2017-08-15 14:34 ` [PATCH net-next 4/4] ipv4: route: set ipv4 " Florian Westphal
@ 2017-08-16  0:21 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2017-08-16  0:21 UTC (permalink / raw)
  To: fw; +Cc: netdev

From: Florian Westphal <fw@strlen.de>
Date: Tue, 15 Aug 2017 16:34:40 +0200

> ipv4 getroute doesn't assume rtnl lock is held anymore, also make
> this true for ipv6, then switch both to DOIT_UNLOCKED.

Series applied, thanks Florian.

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

end of thread, other threads:[~2017-08-16  0:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-15 14:34 [PATCH net-next 0/4] inet: make RTM_GETROUTE work without rtnl Florian Westphal
2017-08-15 14:34 ` [PATCH net-next 1/4] selftests: add 'ip get' to rtnetlink.sh Florian Westphal
2017-08-15 14:34 ` [PATCH net-next 2/4] ipv6: route: make rtm_getroute not assume rtnl is locked Florian Westphal
2017-08-15 14:34 ` [PATCH net-next 3/4] ipv6: route: set ipv6 RTM_GETROUTE to not use rtnl Florian Westphal
2017-08-15 14:34 ` [PATCH net-next 4/4] ipv4: route: set ipv4 " Florian Westphal
2017-08-16  0:21 ` [PATCH net-next 0/4] inet: make RTM_GETROUTE work without rtnl David Miller

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