diff options
Diffstat (limited to 'net/rose/af_rose.c')
-rw-r--r-- | net/rose/af_rose.c | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index f92d5310847b..d476c43d5216 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
@@ -812,26 +812,26 @@ rose_try_next_neigh: | |||
812 | * closed. | 812 | * closed. |
813 | */ | 813 | */ |
814 | if (sk->sk_state == TCP_SYN_SENT) { | 814 | if (sk->sk_state == TCP_SYN_SENT) { |
815 | struct task_struct *tsk = current; | 815 | DEFINE_WAIT(wait); |
816 | DECLARE_WAITQUEUE(wait, tsk); | ||
817 | 816 | ||
818 | add_wait_queue(sk->sk_sleep, &wait); | ||
819 | for (;;) { | 817 | for (;;) { |
820 | set_current_state(TASK_INTERRUPTIBLE); | 818 | prepare_to_wait(sk->sk_sleep, &wait, |
819 | TASK_INTERRUPTIBLE); | ||
821 | if (sk->sk_state != TCP_SYN_SENT) | 820 | if (sk->sk_state != TCP_SYN_SENT) |
822 | break; | 821 | break; |
823 | release_sock(sk); | 822 | if (!signal_pending(current)) { |
824 | if (!signal_pending(tsk)) { | 823 | release_sock(sk); |
825 | schedule(); | 824 | schedule(); |
826 | lock_sock(sk); | 825 | lock_sock(sk); |
827 | continue; | 826 | continue; |
828 | } | 827 | } |
829 | current->state = TASK_RUNNING; | 828 | err = -ERESTARTSYS; |
830 | remove_wait_queue(sk->sk_sleep, &wait); | 829 | break; |
831 | return -ERESTARTSYS; | ||
832 | } | 830 | } |
833 | current->state = TASK_RUNNING; | 831 | finish_wait(sk->sk_sleep, &wait); |
834 | remove_wait_queue(sk->sk_sleep, &wait); | 832 | |
833 | if (err) | ||
834 | goto out_release; | ||
835 | } | 835 | } |
836 | 836 | ||
837 | if (sk->sk_state != TCP_ESTABLISHED) { | 837 | if (sk->sk_state != TCP_ESTABLISHED) { |
@@ -856,10 +856,9 @@ out_release: | |||
856 | 856 | ||
857 | static int rose_accept(struct socket *sock, struct socket *newsock, int flags) | 857 | static int rose_accept(struct socket *sock, struct socket *newsock, int flags) |
858 | { | 858 | { |
859 | struct task_struct *tsk = current; | ||
860 | DECLARE_WAITQUEUE(wait, tsk); | ||
861 | struct sk_buff *skb; | 859 | struct sk_buff *skb; |
862 | struct sock *newsk; | 860 | struct sock *newsk; |
861 | DEFINE_WAIT(wait); | ||
863 | struct sock *sk; | 862 | struct sock *sk; |
864 | int err = 0; | 863 | int err = 0; |
865 | 864 | ||
@@ -869,42 +868,41 @@ static int rose_accept(struct socket *sock, struct socket *newsock, int flags) | |||
869 | lock_sock(sk); | 868 | lock_sock(sk); |
870 | if (sk->sk_type != SOCK_SEQPACKET) { | 869 | if (sk->sk_type != SOCK_SEQPACKET) { |
871 | err = -EOPNOTSUPP; | 870 | err = -EOPNOTSUPP; |
872 | goto out; | 871 | goto out_release; |
873 | } | 872 | } |
874 | 873 | ||
875 | if (sk->sk_state != TCP_LISTEN) { | 874 | if (sk->sk_state != TCP_LISTEN) { |
876 | err = -EINVAL; | 875 | err = -EINVAL; |
877 | goto out; | 876 | goto out_release; |
878 | } | 877 | } |
879 | 878 | ||
880 | /* | 879 | /* |
881 | * The write queue this time is holding sockets ready to use | 880 | * The write queue this time is holding sockets ready to use |
882 | * hooked into the SABM we saved | 881 | * hooked into the SABM we saved |
883 | */ | 882 | */ |
884 | add_wait_queue(sk->sk_sleep, &wait); | ||
885 | for (;;) { | 883 | for (;;) { |
884 | prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE); | ||
885 | |||
886 | skb = skb_dequeue(&sk->sk_receive_queue); | 886 | skb = skb_dequeue(&sk->sk_receive_queue); |
887 | if (skb) | 887 | if (skb) |
888 | break; | 888 | break; |
889 | 889 | ||
890 | current->state = TASK_INTERRUPTIBLE; | ||
891 | release_sock(sk); | ||
892 | if (flags & O_NONBLOCK) { | 890 | if (flags & O_NONBLOCK) { |
893 | current->state = TASK_RUNNING; | 891 | err = -EWOULDBLOCK; |
894 | remove_wait_queue(sk->sk_sleep, &wait); | 892 | break; |
895 | return -EWOULDBLOCK; | ||
896 | } | 893 | } |
897 | if (!signal_pending(tsk)) { | 894 | if (!signal_pending(current)) { |
895 | release_sock(sk); | ||
898 | schedule(); | 896 | schedule(); |
899 | lock_sock(sk); | 897 | lock_sock(sk); |
900 | continue; | 898 | continue; |
901 | } | 899 | } |
902 | current->state = TASK_RUNNING; | 900 | err = -ERESTARTSYS; |
903 | remove_wait_queue(sk->sk_sleep, &wait); | 901 | break; |
904 | return -ERESTARTSYS; | ||
905 | } | 902 | } |
906 | current->state = TASK_RUNNING; | 903 | finish_wait(sk->sk_sleep, &wait); |
907 | remove_wait_queue(sk->sk_sleep, &wait); | 904 | if (err) |
905 | goto out_release; | ||
908 | 906 | ||
909 | newsk = skb->sk; | 907 | newsk = skb->sk; |
910 | newsk->sk_socket = newsock; | 908 | newsk->sk_socket = newsock; |
@@ -916,7 +914,7 @@ static int rose_accept(struct socket *sock, struct socket *newsock, int flags) | |||
916 | sk->sk_ack_backlog--; | 914 | sk->sk_ack_backlog--; |
917 | newsock->sk = newsk; | 915 | newsock->sk = newsk; |
918 | 916 | ||
919 | out: | 917 | out_release: |
920 | release_sock(sk); | 918 | release_sock(sk); |
921 | 919 | ||
922 | return err; | 920 | return err; |
@@ -1105,9 +1103,10 @@ static int rose_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1105 | */ | 1103 | */ |
1106 | SOCK_DEBUG(sk, "ROSE: Appending user data\n"); | 1104 | SOCK_DEBUG(sk, "ROSE: Appending user data\n"); |
1107 | 1105 | ||
1108 | asmptr = skb->h.raw = skb_put(skb, len); | 1106 | skb_reset_transport_header(skb); |
1107 | skb_put(skb, len); | ||
1109 | 1108 | ||
1110 | err = memcpy_fromiovec(asmptr, msg->msg_iov, len); | 1109 | err = memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len); |
1111 | if (err) { | 1110 | if (err) { |
1112 | kfree_skb(skb); | 1111 | kfree_skb(skb); |
1113 | return err; | 1112 | return err; |
@@ -1155,7 +1154,7 @@ static int rose_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1155 | int lg; | 1154 | int lg; |
1156 | 1155 | ||
1157 | /* Save a copy of the Header */ | 1156 | /* Save a copy of the Header */ |
1158 | memcpy(header, skb->data, ROSE_MIN_LEN); | 1157 | skb_copy_from_linear_data(skb, header, ROSE_MIN_LEN); |
1159 | skb_pull(skb, ROSE_MIN_LEN); | 1158 | skb_pull(skb, ROSE_MIN_LEN); |
1160 | 1159 | ||
1161 | frontlen = skb_headroom(skb); | 1160 | frontlen = skb_headroom(skb); |
@@ -1175,12 +1174,12 @@ static int rose_sendmsg(struct kiocb *iocb, struct socket *sock, | |||
1175 | lg = (ROSE_PACLEN > skb->len) ? skb->len : ROSE_PACLEN; | 1174 | lg = (ROSE_PACLEN > skb->len) ? skb->len : ROSE_PACLEN; |
1176 | 1175 | ||
1177 | /* Copy the user data */ | 1176 | /* Copy the user data */ |
1178 | memcpy(skb_put(skbn, lg), skb->data, lg); | 1177 | skb_copy_from_linear_data(skb, skb_put(skbn, lg), lg); |
1179 | skb_pull(skb, lg); | 1178 | skb_pull(skb, lg); |
1180 | 1179 | ||
1181 | /* Duplicate the Header */ | 1180 | /* Duplicate the Header */ |
1182 | skb_push(skbn, ROSE_MIN_LEN); | 1181 | skb_push(skbn, ROSE_MIN_LEN); |
1183 | memcpy(skbn->data, header, ROSE_MIN_LEN); | 1182 | skb_copy_to_linear_data(skbn, header, ROSE_MIN_LEN); |
1184 | 1183 | ||
1185 | if (skb->len > 0) | 1184 | if (skb->len > 0) |
1186 | skbn->data[2] |= M_BIT; | 1185 | skbn->data[2] |= M_BIT; |
@@ -1234,7 +1233,7 @@ static int rose_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
1234 | *asmptr = qbit; | 1233 | *asmptr = qbit; |
1235 | } | 1234 | } |
1236 | 1235 | ||
1237 | skb->h.raw = skb->data; | 1236 | skb_reset_transport_header(skb); |
1238 | copied = skb->len; | 1237 | copied = skb->len; |
1239 | 1238 | ||
1240 | if (copied > size) { | 1239 | if (copied > size) { |
@@ -1296,6 +1295,9 @@ static int rose_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) | |||
1296 | case SIOCGSTAMP: | 1295 | case SIOCGSTAMP: |
1297 | return sock_get_timestamp(sk, (struct timeval __user *) argp); | 1296 | return sock_get_timestamp(sk, (struct timeval __user *) argp); |
1298 | 1297 | ||
1298 | case SIOCGSTAMPNS: | ||
1299 | return sock_get_timestampns(sk, (struct timespec __user *) argp); | ||
1300 | |||
1299 | case SIOCGIFADDR: | 1301 | case SIOCGIFADDR: |
1300 | case SIOCSIFADDR: | 1302 | case SIOCSIFADDR: |
1301 | case SIOCGIFDSTADDR: | 1303 | case SIOCGIFDSTADDR: |