]> err.no Git - linux-2.6/commitdiff
[ICSK] compat: Introduce inet_csk_compat_[gs]etsockopt
authorArnaldo Carvalho de Melo <acme@mandriva.com>
Tue, 21 Mar 2006 06:46:16 +0000 (22:46 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Mar 2006 06:46:16 +0000 (22:46 -0800)
Signed-off-by: Arnaldo Carvalho de Melo <acme@mandriva.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/inet_connection_sock.h
net/dccp/proto.c
net/ipv4/inet_connection_sock.c
net/ipv4/tcp.c

index ae61331366f0954b199f09b911cfa62c96fee2c6..9bf73fe50948e71345ab701e029dc0194b5bda2d 100644 (file)
@@ -331,4 +331,9 @@ extern int inet_csk_ctl_sock_create(struct socket **sock,
                                    unsigned short family,
                                    unsigned short type,
                                    unsigned char protocol);
+
+extern int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname,
+                                     char __user *optval, int __user *optlen);
+extern int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname,
+                                     char __user *optval, int optlen);
 #endif /* _INET_CONNECTION_SOCK_H */
index 59b214995f28e517689000054a0262f114442fae..6d7aef9647ded7e16c3959444060eabe55b5a5bd 100644 (file)
@@ -522,14 +522,10 @@ EXPORT_SYMBOL_GPL(dccp_setsockopt);
 int compat_dccp_setsockopt(struct sock *sk, int level, int optname,
                    char __user *optval, int optlen)
 {
-       if (level != SOL_DCCP) {
-               if (inet_csk(sk)->icsk_af_ops->compat_setsockopt)
-                       return inet_csk(sk)->icsk_af_ops->compat_setsockopt(sk,
-                               level, optname, optval, optlen);
-               else
-                       return inet_csk(sk)->icsk_af_ops->setsockopt(sk,
-                               level, optname, optval, optlen);
-       }
+       if (level != SOL_DCCP)
+               return inet_csk_compat_setsockopt(sk, level, optname,
+                                                 optval, optlen);
+
        return do_dccp_setsockopt(sk, level, optname, optval, optlen);
 }
 EXPORT_SYMBOL_GPL(compat_dccp_setsockopt);
@@ -619,14 +615,9 @@ EXPORT_SYMBOL_GPL(dccp_getsockopt);
 int compat_dccp_getsockopt(struct sock *sk, int level, int optname,
                    char __user *optval, int __user *optlen)
 {
-       if (level != SOL_DCCP) {
-               if (inet_csk(sk)->icsk_af_ops->compat_setsockopt)
-                       return inet_csk(sk)->icsk_af_ops->compat_getsockopt(sk,
-                               level, optname, optval, optlen);
-               else
-                       return inet_csk(sk)->icsk_af_ops->getsockopt(sk,
-                               level, optname, optval, optlen);
-       }
+       if (level != SOL_DCCP)
+               return inet_csk_compat_getsockopt(sk, level, optname,
+                                                 optval, optlen);
        return do_dccp_getsockopt(sk, level, optname, optval, optlen);
 }
 EXPORT_SYMBOL_GPL(compat_dccp_getsockopt);
index 359f48cec99a52fc7dd3a9d3f41033ca2253e2ce..9f6b44ca28a88861e702102406bc5835b870d489 100644 (file)
@@ -667,3 +667,33 @@ int inet_csk_ctl_sock_create(struct socket **sock, unsigned short family,
 }
 
 EXPORT_SYMBOL_GPL(inet_csk_ctl_sock_create);
+
+#ifdef CONFIG_COMPAT
+int inet_csk_compat_getsockopt(struct sock *sk, int level, int optname,
+                              char __user *optval, int __user *optlen)
+{
+       const struct inet_csk *icsk = inet_csk(sk);
+
+       if (icsk->icsk_af_ops->compat_getsockopt != NULL)
+               return icsk->icsk_af_ops->compat_getsockopt(sk, level, optname,
+                                                           optval, optlen);
+       return icsk->icsk_af_ops->getsockopt(sk, level, optname,
+                                            optval, optlen);
+}
+
+EXPORT_SYMBOL_GPL(inet_csk_compat_getsockopt);
+
+int inet_csk_compat_setsockopt(struct sock *sk, int level, int optname,
+                              char __user *optval, int optlen)
+{
+       const struct inet_csk *icsk = inet_csk(sk);
+
+       if (icsk->icsk_af_ops->compat_setsockopt != NULL)
+               return icsk->icsk_af_ops->compat_setsockopt(sk, level, optname,
+                                                           optval, optlen);
+       return icsk->icsk_af_ops->setsockopt(sk, level, optname,
+                                            optval, optlen);
+}
+
+EXPORT_SYMBOL_GPL(inet_csk_compat_setsockopt);
+#endif
index 31b0123a96993f74bd555a19af37e91c6e69eddf..89da253e33f0dc92eb628f8e0cea35d2f2159f5c 100644 (file)
@@ -1882,16 +1882,9 @@ int tcp_setsockopt(struct sock *sk, int level, int optname, char __user *optval,
 int compat_tcp_setsockopt(struct sock *sk, int level,
                int optname, char __user *optval, int optlen)
 {
-       struct inet_connection_sock *icsk = inet_csk(sk);
-
-       if (level != SOL_TCP) {
-               if (icsk->icsk_af_ops->compat_setsockopt)
-                       return icsk->icsk_af_ops->compat_setsockopt(sk,
-                               level, optname, optval, optlen);
-               else
-                       return icsk->icsk_af_ops->setsockopt(sk,
-                               level, optname, optval, optlen);
-       }
+       if (level != SOL_TCP)
+               return inet_csk_compat_setsockopt(sk, level, optname,
+                                                 optval, optlen);
        return do_tcp_setsockopt(sk, level, optname, optval, optlen);
 }
 #endif
@@ -2061,16 +2054,9 @@ int tcp_getsockopt(struct sock *sk, int level, int optname, char __user *optval,
 int compat_tcp_getsockopt(struct sock *sk, int level,
                int optname, char __user *optval, int __user *optlen)
 {
-       struct inet_connection_sock *icsk = inet_csk(sk);
-
-       if (level != SOL_TCP) {
-               if (icsk->icsk_af_ops->compat_getsockopt)
-                       return icsk->icsk_af_ops->compat_getsockopt(sk,
-                               level, optname, optval, optlen);
-               else
-                       return icsk->icsk_af_ops->getsockopt(sk,
-                               level, optname, optval, optlen);
-       }
+       if (level != SOL_TCP)
+               return inet_csk_compat_getsockopt(sk, level, optname,
+                                                 optval, optlen);
        return do_tcp_getsockopt(sk, level, optname, optval, optlen);
 }
 #endif