Commit 5d1321a9 authored by David S. Miller's avatar David S. Miller

Merge branch 'getroute-no-rtnl'

Florian Westphal says:

====================
ipv4 getroute doesn't assume rtnl lock is held anymore, also make
this true for ipv6, then switch both to DOIT_UNLOCKED.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 7324157b 394f51ab
...@@ -3073,7 +3073,8 @@ int __init ip_rt_init(void) ...@@ -3073,7 +3073,8 @@ int __init ip_rt_init(void)
xfrm_init(); xfrm_init();
xfrm4_init(); xfrm4_init();
#endif #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 #ifdef CONFIG_SYSCTL
register_pernet_subsys(&sysctl_route_ops); register_pernet_subsys(&sysctl_route_ops);
......
...@@ -3611,8 +3611,11 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, ...@@ -3611,8 +3611,11 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
struct net_device *dev; struct net_device *dev;
int flags = 0; int flags = 0;
dev = __dev_get_by_index(net, iif); rcu_read_lock();
dev = dev_get_by_index_rcu(net, iif);
if (!dev) { if (!dev) {
rcu_read_unlock();
err = -ENODEV; err = -ENODEV;
goto errout; goto errout;
} }
...@@ -3624,6 +3627,8 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh, ...@@ -3624,6 +3627,8 @@ static int inet6_rtm_getroute(struct sk_buff *in_skb, struct nlmsghdr *nlh,
if (!fibmatch) if (!fibmatch)
dst = ip6_route_input_lookup(net, dev, &fl6, flags); dst = ip6_route_input_lookup(net, dev, &fl6, flags);
rcu_read_unlock();
} else { } else {
fl6.flowi6_oif = oif; fl6.flowi6_oif = oif;
...@@ -4102,7 +4107,8 @@ int __init ip6_route_init(void) ...@@ -4102,7 +4107,8 @@ int __init ip6_route_init(void)
ret = -ENOBUFS; ret = -ENOBUFS;
if (__rtnl_register(PF_INET6, RTM_NEWROUTE, inet6_rtm_newroute, NULL, 0) || 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_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; goto out_register_late_subsys;
ret = register_netdevice_notifier(&ip6_route_dev_notifier); ret = register_netdevice_notifier(&ip6_route_dev_notifier);
......
...@@ -164,6 +164,37 @@ kci_test_polrouting() ...@@ -164,6 +164,37 @@ kci_test_polrouting()
echo "PASS: policy routing" 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_test_rtnl()
{ {
kci_add_dummy kci_add_dummy
...@@ -173,6 +204,7 @@ kci_test_rtnl() ...@@ -173,6 +204,7 @@ kci_test_rtnl()
fi fi
kci_test_polrouting kci_test_polrouting
kci_test_route_get
kci_test_tc kci_test_tc
kci_test_gre kci_test_gre
kci_test_bridge kci_test_bridge
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment