diff options
author | Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> | 2015-03-18 13:50:43 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-18 22:05:09 -0400 |
commit | 54ff9ef36bdf84d469a098cbf8e2a103fbc77054 (patch) | |
tree | 74fb6219d97f44685a80b090888ffd5ea667e01e /net/ipv4/ip_sockglue.c | |
parent | baf606d9c9b12517e47e0d1370e8aa9f7323f210 (diff) |
ipv4, ipv6: kill ip_mc_{join, leave}_group and ipv6_sock_mc_{join, drop}
in favor of their inner __ ones, which doesn't grab rtnl.
As these functions need to operate on a locked socket, we can't be
grabbing rtnl by then. It's too late and doing so causes reversed
locking.
So this patch:
- move rtnl handling to callers instead while already fixing some
reversed locking situations, like on vxlan and ipvs code.
- renames __ ones to not have the __ mark:
__ip_mc_{join,leave}_group -> ip_mc_{join,leave}_group
__ipv6_sock_mc_{join,drop} -> ipv6_sock_mc_{join,drop}
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/ip_sockglue.c')
-rw-r--r-- | net/ipv4/ip_sockglue.c | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index 5171709199f4..f6a0d54b308a 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c | |||
@@ -541,9 +541,18 @@ static bool setsockopt_needs_rtnl(int optname) | |||
541 | switch (optname) { | 541 | switch (optname) { |
542 | case IP_ADD_MEMBERSHIP: | 542 | case IP_ADD_MEMBERSHIP: |
543 | case IP_ADD_SOURCE_MEMBERSHIP: | 543 | case IP_ADD_SOURCE_MEMBERSHIP: |
544 | case IP_BLOCK_SOURCE: | ||
544 | case IP_DROP_MEMBERSHIP: | 545 | case IP_DROP_MEMBERSHIP: |
546 | case IP_DROP_SOURCE_MEMBERSHIP: | ||
547 | case IP_MSFILTER: | ||
548 | case IP_UNBLOCK_SOURCE: | ||
549 | case MCAST_BLOCK_SOURCE: | ||
550 | case MCAST_MSFILTER: | ||
545 | case MCAST_JOIN_GROUP: | 551 | case MCAST_JOIN_GROUP: |
552 | case MCAST_JOIN_SOURCE_GROUP: | ||
546 | case MCAST_LEAVE_GROUP: | 553 | case MCAST_LEAVE_GROUP: |
554 | case MCAST_LEAVE_SOURCE_GROUP: | ||
555 | case MCAST_UNBLOCK_SOURCE: | ||
547 | return true; | 556 | return true; |
548 | } | 557 | } |
549 | return false; | 558 | return false; |
@@ -861,9 +870,9 @@ static int do_ip_setsockopt(struct sock *sk, int level, | |||
861 | } | 870 | } |
862 | 871 | ||
863 | if (optname == IP_ADD_MEMBERSHIP) | 872 | if (optname == IP_ADD_MEMBERSHIP) |
864 | err = __ip_mc_join_group(sk, &mreq); | 873 | err = ip_mc_join_group(sk, &mreq); |
865 | else | 874 | else |
866 | err = __ip_mc_leave_group(sk, &mreq); | 875 | err = ip_mc_leave_group(sk, &mreq); |
867 | break; | 876 | break; |
868 | } | 877 | } |
869 | case IP_MSFILTER: | 878 | case IP_MSFILTER: |
@@ -928,7 +937,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, | |||
928 | mreq.imr_multiaddr.s_addr = mreqs.imr_multiaddr; | 937 | mreq.imr_multiaddr.s_addr = mreqs.imr_multiaddr; |
929 | mreq.imr_address.s_addr = mreqs.imr_interface; | 938 | mreq.imr_address.s_addr = mreqs.imr_interface; |
930 | mreq.imr_ifindex = 0; | 939 | mreq.imr_ifindex = 0; |
931 | err = __ip_mc_join_group(sk, &mreq); | 940 | err = ip_mc_join_group(sk, &mreq); |
932 | if (err && err != -EADDRINUSE) | 941 | if (err && err != -EADDRINUSE) |
933 | break; | 942 | break; |
934 | omode = MCAST_INCLUDE; | 943 | omode = MCAST_INCLUDE; |
@@ -960,9 +969,9 @@ static int do_ip_setsockopt(struct sock *sk, int level, | |||
960 | mreq.imr_ifindex = greq.gr_interface; | 969 | mreq.imr_ifindex = greq.gr_interface; |
961 | 970 | ||
962 | if (optname == MCAST_JOIN_GROUP) | 971 | if (optname == MCAST_JOIN_GROUP) |
963 | err = __ip_mc_join_group(sk, &mreq); | 972 | err = ip_mc_join_group(sk, &mreq); |
964 | else | 973 | else |
965 | err = __ip_mc_leave_group(sk, &mreq); | 974 | err = ip_mc_leave_group(sk, &mreq); |
966 | break; | 975 | break; |
967 | } | 976 | } |
968 | case MCAST_JOIN_SOURCE_GROUP: | 977 | case MCAST_JOIN_SOURCE_GROUP: |
@@ -1005,7 +1014,7 @@ static int do_ip_setsockopt(struct sock *sk, int level, | |||
1005 | mreq.imr_multiaddr = psin->sin_addr; | 1014 | mreq.imr_multiaddr = psin->sin_addr; |
1006 | mreq.imr_address.s_addr = 0; | 1015 | mreq.imr_address.s_addr = 0; |
1007 | mreq.imr_ifindex = greqs.gsr_interface; | 1016 | mreq.imr_ifindex = greqs.gsr_interface; |
1008 | err = __ip_mc_join_group(sk, &mreq); | 1017 | err = ip_mc_join_group(sk, &mreq); |
1009 | if (err && err != -EADDRINUSE) | 1018 | if (err && err != -EADDRINUSE) |
1010 | break; | 1019 | break; |
1011 | greqs.gsr_interface = mreq.imr_ifindex; | 1020 | greqs.gsr_interface = mreq.imr_ifindex; |