diff options
Diffstat (limited to 'net/ipv6/udp.c')
-rw-r--r-- | net/ipv6/udp.c | 84 |
1 files changed, 60 insertions, 24 deletions
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index c47648892c04..8d3432a70f3a 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
@@ -880,16 +880,13 @@ static int udpv6_destroy_sock(struct sock *sk) | |||
880 | /* | 880 | /* |
881 | * Socket option code for UDP | 881 | * Socket option code for UDP |
882 | */ | 882 | */ |
883 | static int udpv6_setsockopt(struct sock *sk, int level, int optname, | 883 | static int do_udpv6_setsockopt(struct sock *sk, int level, int optname, |
884 | char __user *optval, int optlen) | 884 | char __user *optval, int optlen) |
885 | { | 885 | { |
886 | struct udp_sock *up = udp_sk(sk); | 886 | struct udp_sock *up = udp_sk(sk); |
887 | int val; | 887 | int val; |
888 | int err = 0; | 888 | int err = 0; |
889 | 889 | ||
890 | if (level != SOL_UDP) | ||
891 | return ipv6_setsockopt(sk, level, optname, optval, optlen); | ||
892 | |||
893 | if(optlen<sizeof(int)) | 890 | if(optlen<sizeof(int)) |
894 | return -EINVAL; | 891 | return -EINVAL; |
895 | 892 | ||
@@ -927,15 +924,31 @@ static int udpv6_setsockopt(struct sock *sk, int level, int optname, | |||
927 | return err; | 924 | return err; |
928 | } | 925 | } |
929 | 926 | ||
930 | static int udpv6_getsockopt(struct sock *sk, int level, int optname, | 927 | static int udpv6_setsockopt(struct sock *sk, int level, int optname, |
928 | char __user *optval, int optlen) | ||
929 | { | ||
930 | if (level != SOL_UDP) | ||
931 | return ipv6_setsockopt(sk, level, optname, optval, optlen); | ||
932 | return do_udpv6_setsockopt(sk, level, optname, optval, optlen); | ||
933 | } | ||
934 | |||
935 | #ifdef CONFIG_COMPAT | ||
936 | static int compat_udpv6_setsockopt(struct sock *sk, int level, int optname, | ||
937 | char __user *optval, int optlen) | ||
938 | { | ||
939 | if (level != SOL_UDP) | ||
940 | return compat_ipv6_setsockopt(sk, level, optname, | ||
941 | optval, optlen); | ||
942 | return do_udpv6_setsockopt(sk, level, optname, optval, optlen); | ||
943 | } | ||
944 | #endif | ||
945 | |||
946 | static int do_udpv6_getsockopt(struct sock *sk, int level, int optname, | ||
931 | char __user *optval, int __user *optlen) | 947 | char __user *optval, int __user *optlen) |
932 | { | 948 | { |
933 | struct udp_sock *up = udp_sk(sk); | 949 | struct udp_sock *up = udp_sk(sk); |
934 | int val, len; | 950 | int val, len; |
935 | 951 | ||
936 | if (level != SOL_UDP) | ||
937 | return ipv6_getsockopt(sk, level, optname, optval, optlen); | ||
938 | |||
939 | if(get_user(len,optlen)) | 952 | if(get_user(len,optlen)) |
940 | return -EFAULT; | 953 | return -EFAULT; |
941 | 954 | ||
@@ -964,6 +977,25 @@ static int udpv6_getsockopt(struct sock *sk, int level, int optname, | |||
964 | return 0; | 977 | return 0; |
965 | } | 978 | } |
966 | 979 | ||
980 | static int udpv6_getsockopt(struct sock *sk, int level, int optname, | ||
981 | char __user *optval, int __user *optlen) | ||
982 | { | ||
983 | if (level != SOL_UDP) | ||
984 | return ipv6_getsockopt(sk, level, optname, optval, optlen); | ||
985 | return do_udpv6_getsockopt(sk, level, optname, optval, optlen); | ||
986 | } | ||
987 | |||
988 | #ifdef CONFIG_COMPAT | ||
989 | static int compat_udpv6_getsockopt(struct sock *sk, int level, int optname, | ||
990 | char __user *optval, int __user *optlen) | ||
991 | { | ||
992 | if (level != SOL_UDP) | ||
993 | return compat_ipv6_getsockopt(sk, level, optname, | ||
994 | optval, optlen); | ||
995 | return do_udpv6_getsockopt(sk, level, optname, optval, optlen); | ||
996 | } | ||
997 | #endif | ||
998 | |||
967 | static struct inet6_protocol udpv6_protocol = { | 999 | static struct inet6_protocol udpv6_protocol = { |
968 | .handler = udpv6_rcv, | 1000 | .handler = udpv6_rcv, |
969 | .err_handler = udpv6_err, | 1001 | .err_handler = udpv6_err, |
@@ -1037,22 +1069,26 @@ void udp6_proc_exit(void) { | |||
1037 | /* ------------------------------------------------------------------------ */ | 1069 | /* ------------------------------------------------------------------------ */ |
1038 | 1070 | ||
1039 | struct proto udpv6_prot = { | 1071 | struct proto udpv6_prot = { |
1040 | .name = "UDPv6", | 1072 | .name = "UDPv6", |
1041 | .owner = THIS_MODULE, | 1073 | .owner = THIS_MODULE, |
1042 | .close = udpv6_close, | 1074 | .close = udpv6_close, |
1043 | .connect = ip6_datagram_connect, | 1075 | .connect = ip6_datagram_connect, |
1044 | .disconnect = udp_disconnect, | 1076 | .disconnect = udp_disconnect, |
1045 | .ioctl = udp_ioctl, | 1077 | .ioctl = udp_ioctl, |
1046 | .destroy = udpv6_destroy_sock, | 1078 | .destroy = udpv6_destroy_sock, |
1047 | .setsockopt = udpv6_setsockopt, | 1079 | .setsockopt = udpv6_setsockopt, |
1048 | .getsockopt = udpv6_getsockopt, | 1080 | .getsockopt = udpv6_getsockopt, |
1049 | .sendmsg = udpv6_sendmsg, | 1081 | .sendmsg = udpv6_sendmsg, |
1050 | .recvmsg = udpv6_recvmsg, | 1082 | .recvmsg = udpv6_recvmsg, |
1051 | .backlog_rcv = udpv6_queue_rcv_skb, | 1083 | .backlog_rcv = udpv6_queue_rcv_skb, |
1052 | .hash = udp_v6_hash, | 1084 | .hash = udp_v6_hash, |
1053 | .unhash = udp_v6_unhash, | 1085 | .unhash = udp_v6_unhash, |
1054 | .get_port = udp_v6_get_port, | 1086 | .get_port = udp_v6_get_port, |
1055 | .obj_size = sizeof(struct udp6_sock), | 1087 | .obj_size = sizeof(struct udp6_sock), |
1088 | #ifdef CONFIG_COMPAT | ||
1089 | .compat_setsockopt = compat_udpv6_setsockopt, | ||
1090 | .compat_getsockopt = compat_udpv6_getsockopt, | ||
1091 | #endif | ||
1056 | }; | 1092 | }; |
1057 | 1093 | ||
1058 | static struct inet_protosw udpv6_protosw = { | 1094 | static struct inet_protosw udpv6_protosw = { |