diff options
-rw-r--r-- | include/net/netns/ipv4.h | 4 | ||||
-rw-r--r-- | net/ipv4/ipmr.c | 28 |
2 files changed, 17 insertions, 15 deletions
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h index 977f482d97a9..4f00722c7478 100644 --- a/include/net/netns/ipv4.h +++ b/include/net/netns/ipv4.h | |||
@@ -54,5 +54,9 @@ struct netns_ipv4 { | |||
54 | 54 | ||
55 | struct timer_list rt_secret_timer; | 55 | struct timer_list rt_secret_timer; |
56 | atomic_t rt_genid; | 56 | atomic_t rt_genid; |
57 | |||
58 | #ifdef CONFIG_IP_MROUTE | ||
59 | struct sock *mroute_sk; | ||
60 | #endif | ||
57 | }; | 61 | }; |
58 | #endif | 62 | #endif |
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c index 14666449dc1c..ac324b702e8b 100644 --- a/net/ipv4/ipmr.c +++ b/net/ipv4/ipmr.c | |||
@@ -67,9 +67,6 @@ | |||
67 | #define CONFIG_IP_PIMSM 1 | 67 | #define CONFIG_IP_PIMSM 1 |
68 | #endif | 68 | #endif |
69 | 69 | ||
70 | static struct sock *mroute_socket; | ||
71 | |||
72 | |||
73 | /* Big lock, protecting vif table, mrt cache and mroute socket state. | 70 | /* Big lock, protecting vif table, mrt cache and mroute socket state. |
74 | Note that the changes are semaphored via rtnl_lock. | 71 | Note that the changes are semaphored via rtnl_lock. |
75 | */ | 72 | */ |
@@ -658,7 +655,7 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) | |||
658 | skb->transport_header = skb->network_header; | 655 | skb->transport_header = skb->network_header; |
659 | } | 656 | } |
660 | 657 | ||
661 | if (mroute_socket == NULL) { | 658 | if (init_net.ipv4.mroute_sk == NULL) { |
662 | kfree_skb(skb); | 659 | kfree_skb(skb); |
663 | return -EINVAL; | 660 | return -EINVAL; |
664 | } | 661 | } |
@@ -666,7 +663,8 @@ static int ipmr_cache_report(struct sk_buff *pkt, vifi_t vifi, int assert) | |||
666 | /* | 663 | /* |
667 | * Deliver to mrouted | 664 | * Deliver to mrouted |
668 | */ | 665 | */ |
669 | if ((ret = sock_queue_rcv_skb(mroute_socket, skb))<0) { | 666 | ret = sock_queue_rcv_skb(init_net.ipv4.mroute_sk, skb); |
667 | if (ret < 0) { | ||
670 | if (net_ratelimit()) | 668 | if (net_ratelimit()) |
671 | printk(KERN_WARNING "mroute: pending queue full, dropping entries.\n"); | 669 | printk(KERN_WARNING "mroute: pending queue full, dropping entries.\n"); |
672 | kfree_skb(skb); | 670 | kfree_skb(skb); |
@@ -896,11 +894,11 @@ static void mroute_clean_tables(struct sock *sk) | |||
896 | static void mrtsock_destruct(struct sock *sk) | 894 | static void mrtsock_destruct(struct sock *sk) |
897 | { | 895 | { |
898 | rtnl_lock(); | 896 | rtnl_lock(); |
899 | if (sk == mroute_socket) { | 897 | if (sk == init_net.ipv4.mroute_sk) { |
900 | IPV4_DEVCONF_ALL(sock_net(sk), MC_FORWARDING)--; | 898 | IPV4_DEVCONF_ALL(sock_net(sk), MC_FORWARDING)--; |
901 | 899 | ||
902 | write_lock_bh(&mrt_lock); | 900 | write_lock_bh(&mrt_lock); |
903 | mroute_socket = NULL; | 901 | init_net.ipv4.mroute_sk = NULL; |
904 | write_unlock_bh(&mrt_lock); | 902 | write_unlock_bh(&mrt_lock); |
905 | 903 | ||
906 | mroute_clean_tables(sk); | 904 | mroute_clean_tables(sk); |
@@ -922,7 +920,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int | |||
922 | struct mfcctl mfc; | 920 | struct mfcctl mfc; |
923 | 921 | ||
924 | if (optname != MRT_INIT) { | 922 | if (optname != MRT_INIT) { |
925 | if (sk != mroute_socket && !capable(CAP_NET_ADMIN)) | 923 | if (sk != init_net.ipv4.mroute_sk && !capable(CAP_NET_ADMIN)) |
926 | return -EACCES; | 924 | return -EACCES; |
927 | } | 925 | } |
928 | 926 | ||
@@ -935,7 +933,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int | |||
935 | return -ENOPROTOOPT; | 933 | return -ENOPROTOOPT; |
936 | 934 | ||
937 | rtnl_lock(); | 935 | rtnl_lock(); |
938 | if (mroute_socket) { | 936 | if (init_net.ipv4.mroute_sk) { |
939 | rtnl_unlock(); | 937 | rtnl_unlock(); |
940 | return -EADDRINUSE; | 938 | return -EADDRINUSE; |
941 | } | 939 | } |
@@ -943,7 +941,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int | |||
943 | ret = ip_ra_control(sk, 1, mrtsock_destruct); | 941 | ret = ip_ra_control(sk, 1, mrtsock_destruct); |
944 | if (ret == 0) { | 942 | if (ret == 0) { |
945 | write_lock_bh(&mrt_lock); | 943 | write_lock_bh(&mrt_lock); |
946 | mroute_socket = sk; | 944 | init_net.ipv4.mroute_sk = sk; |
947 | write_unlock_bh(&mrt_lock); | 945 | write_unlock_bh(&mrt_lock); |
948 | 946 | ||
949 | IPV4_DEVCONF_ALL(sock_net(sk), MC_FORWARDING)++; | 947 | IPV4_DEVCONF_ALL(sock_net(sk), MC_FORWARDING)++; |
@@ -951,7 +949,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int | |||
951 | rtnl_unlock(); | 949 | rtnl_unlock(); |
952 | return ret; | 950 | return ret; |
953 | case MRT_DONE: | 951 | case MRT_DONE: |
954 | if (sk != mroute_socket) | 952 | if (sk != init_net.ipv4.mroute_sk) |
955 | return -EACCES; | 953 | return -EACCES; |
956 | return ip_ra_control(sk, 0, NULL); | 954 | return ip_ra_control(sk, 0, NULL); |
957 | case MRT_ADD_VIF: | 955 | case MRT_ADD_VIF: |
@@ -964,7 +962,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int | |||
964 | return -ENFILE; | 962 | return -ENFILE; |
965 | rtnl_lock(); | 963 | rtnl_lock(); |
966 | if (optname == MRT_ADD_VIF) { | 964 | if (optname == MRT_ADD_VIF) { |
967 | ret = vif_add(&vif, sk==mroute_socket); | 965 | ret = vif_add(&vif, sk == init_net.ipv4.mroute_sk); |
968 | } else { | 966 | } else { |
969 | ret = vif_delete(vif.vifc_vifi, 0); | 967 | ret = vif_delete(vif.vifc_vifi, 0); |
970 | } | 968 | } |
@@ -985,7 +983,7 @@ int ip_mroute_setsockopt(struct sock *sk, int optname, char __user *optval, int | |||
985 | if (optname == MRT_DEL_MFC) | 983 | if (optname == MRT_DEL_MFC) |
986 | ret = ipmr_mfc_delete(&mfc); | 984 | ret = ipmr_mfc_delete(&mfc); |
987 | else | 985 | else |
988 | ret = ipmr_mfc_add(&mfc, sk==mroute_socket); | 986 | ret = ipmr_mfc_add(&mfc, sk == init_net.ipv4.mroute_sk); |
989 | rtnl_unlock(); | 987 | rtnl_unlock(); |
990 | return ret; | 988 | return ret; |
991 | /* | 989 | /* |
@@ -1425,9 +1423,9 @@ int ip_mr_input(struct sk_buff *skb) | |||
1425 | that we can forward NO IGMP messages. | 1423 | that we can forward NO IGMP messages. |
1426 | */ | 1424 | */ |
1427 | read_lock(&mrt_lock); | 1425 | read_lock(&mrt_lock); |
1428 | if (mroute_socket) { | 1426 | if (init_net.ipv4.mroute_sk) { |
1429 | nf_reset(skb); | 1427 | nf_reset(skb); |
1430 | raw_rcv(mroute_socket, skb); | 1428 | raw_rcv(init_net.ipv4.mroute_sk, skb); |
1431 | read_unlock(&mrt_lock); | 1429 | read_unlock(&mrt_lock); |
1432 | return 0; | 1430 | return 0; |
1433 | } | 1431 | } |