aboutsummaryrefslogtreecommitdiffstats
path: root/net/netrom
diff options
context:
space:
mode:
Diffstat (limited to 'net/netrom')
-rw-r--r--net/netrom/af_netrom.c115
-rw-r--r--net/netrom/nr_dev.c4
-rw-r--r--net/netrom/nr_in.c6
-rw-r--r--net/netrom/nr_loopback.c4
-rw-r--r--net/netrom/nr_out.c8
-rw-r--r--net/netrom/nr_subr.c4
6 files changed, 74 insertions, 67 deletions
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
index bf9837dd95c4..5d4a26c2aa0c 100644
--- a/net/netrom/af_netrom.c
+++ b/net/netrom/af_netrom.c
@@ -625,42 +625,42 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr,
625 ax25_address *source = NULL; 625 ax25_address *source = NULL;
626 ax25_uid_assoc *user; 626 ax25_uid_assoc *user;
627 struct net_device *dev; 627 struct net_device *dev;
628 int err = 0;
628 629
629 lock_sock(sk); 630 lock_sock(sk);
630 if (sk->sk_state == TCP_ESTABLISHED && sock->state == SS_CONNECTING) { 631 if (sk->sk_state == TCP_ESTABLISHED && sock->state == SS_CONNECTING) {
631 sock->state = SS_CONNECTED; 632 sock->state = SS_CONNECTED;
632 release_sock(sk); 633 goto out_release; /* Connect completed during a ERESTARTSYS event */
633 return 0; /* Connect completed during a ERESTARTSYS event */
634 } 634 }
635 635
636 if (sk->sk_state == TCP_CLOSE && sock->state == SS_CONNECTING) { 636 if (sk->sk_state == TCP_CLOSE && sock->state == SS_CONNECTING) {
637 sock->state = SS_UNCONNECTED; 637 sock->state = SS_UNCONNECTED;
638 release_sock(sk); 638 err = -ECONNREFUSED;
639 return -ECONNREFUSED; 639 goto out_release;
640 } 640 }
641 641
642 if (sk->sk_state == TCP_ESTABLISHED) { 642 if (sk->sk_state == TCP_ESTABLISHED) {
643 release_sock(sk); 643 err = -EISCONN; /* No reconnect on a seqpacket socket */
644 return -EISCONN; /* No reconnect on a seqpacket socket */ 644 goto out_release;
645 } 645 }
646 646
647 sk->sk_state = TCP_CLOSE; 647 sk->sk_state = TCP_CLOSE;
648 sock->state = SS_UNCONNECTED; 648 sock->state = SS_UNCONNECTED;
649 649
650 if (addr_len != sizeof(struct sockaddr_ax25) && addr_len != sizeof(struct full_sockaddr_ax25)) { 650 if (addr_len != sizeof(struct sockaddr_ax25) && addr_len != sizeof(struct full_sockaddr_ax25)) {
651 release_sock(sk); 651 err = -EINVAL;
652 return -EINVAL; 652 goto out_release;
653 } 653 }
654 if (addr->sax25_family != AF_NETROM) { 654 if (addr->sax25_family != AF_NETROM) {
655 release_sock(sk); 655 err = -EINVAL;
656 return -EINVAL; 656 goto out_release;
657 } 657 }
658 if (sock_flag(sk, SOCK_ZAPPED)) { /* Must bind first - autobinding in this may or may not work */ 658 if (sock_flag(sk, SOCK_ZAPPED)) { /* Must bind first - autobinding in this may or may not work */
659 sock_reset_flag(sk, SOCK_ZAPPED); 659 sock_reset_flag(sk, SOCK_ZAPPED);
660 660
661 if ((dev = nr_dev_first()) == NULL) { 661 if ((dev = nr_dev_first()) == NULL) {
662 release_sock(sk); 662 err = -ENETUNREACH;
663 return -ENETUNREACH; 663 goto out_release;
664 } 664 }
665 source = (ax25_address *)dev->dev_addr; 665 source = (ax25_address *)dev->dev_addr;
666 666
@@ -671,8 +671,8 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr,
671 } else { 671 } else {
672 if (ax25_uid_policy && !capable(CAP_NET_ADMIN)) { 672 if (ax25_uid_policy && !capable(CAP_NET_ADMIN)) {
673 dev_put(dev); 673 dev_put(dev);
674 release_sock(sk); 674 err = -EPERM;
675 return -EPERM; 675 goto out_release;
676 } 676 }
677 nr->user_addr = *source; 677 nr->user_addr = *source;
678 } 678 }
@@ -707,8 +707,8 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr,
707 707
708 /* Now the loop */ 708 /* Now the loop */
709 if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK)) { 709 if (sk->sk_state != TCP_ESTABLISHED && (flags & O_NONBLOCK)) {
710 release_sock(sk); 710 err = -EINPROGRESS;
711 return -EINPROGRESS; 711 goto out_release;
712 } 712 }
713 713
714 /* 714 /*
@@ -716,46 +716,46 @@ static int nr_connect(struct socket *sock, struct sockaddr *uaddr,
716 * closed. 716 * closed.
717 */ 717 */
718 if (sk->sk_state == TCP_SYN_SENT) { 718 if (sk->sk_state == TCP_SYN_SENT) {
719 struct task_struct *tsk = current; 719 DEFINE_WAIT(wait);
720 DECLARE_WAITQUEUE(wait, tsk);
721 720
722 add_wait_queue(sk->sk_sleep, &wait);
723 for (;;) { 721 for (;;) {
724 set_current_state(TASK_INTERRUPTIBLE); 722 prepare_to_wait(sk->sk_sleep, &wait,
723 TASK_INTERRUPTIBLE);
725 if (sk->sk_state != TCP_SYN_SENT) 724 if (sk->sk_state != TCP_SYN_SENT)
726 break; 725 break;
727 release_sock(sk); 726 if (!signal_pending(current)) {
728 if (!signal_pending(tsk)) { 727 release_sock(sk);
729 schedule(); 728 schedule();
730 lock_sock(sk); 729 lock_sock(sk);
731 continue; 730 continue;
732 } 731 }
733 current->state = TASK_RUNNING; 732 err = -ERESTARTSYS;
734 remove_wait_queue(sk->sk_sleep, &wait); 733 break;
735 return -ERESTARTSYS;
736 } 734 }
737 current->state = TASK_RUNNING; 735 finish_wait(sk->sk_sleep, &wait);
738 remove_wait_queue(sk->sk_sleep, &wait); 736 if (err)
737 goto out_release;
739 } 738 }
740 739
741 if (sk->sk_state != TCP_ESTABLISHED) { 740 if (sk->sk_state != TCP_ESTABLISHED) {
742 sock->state = SS_UNCONNECTED; 741 sock->state = SS_UNCONNECTED;
743 release_sock(sk); 742 err = sock_error(sk); /* Always set at this point */
744 return sock_error(sk); /* Always set at this point */ 743 goto out_release;
745 } 744 }
746 745
747 sock->state = SS_CONNECTED; 746 sock->state = SS_CONNECTED;
747
748out_release:
748 release_sock(sk); 749 release_sock(sk);
749 750
750 return 0; 751 return err;
751} 752}
752 753
753static int nr_accept(struct socket *sock, struct socket *newsock, int flags) 754static int nr_accept(struct socket *sock, struct socket *newsock, int flags)
754{ 755{
755 struct task_struct *tsk = current;
756 DECLARE_WAITQUEUE(wait, tsk);
757 struct sk_buff *skb; 756 struct sk_buff *skb;
758 struct sock *newsk; 757 struct sock *newsk;
758 DEFINE_WAIT(wait);
759 struct sock *sk; 759 struct sock *sk;
760 int err = 0; 760 int err = 0;
761 761
@@ -765,42 +765,40 @@ static int nr_accept(struct socket *sock, struct socket *newsock, int flags)
765 lock_sock(sk); 765 lock_sock(sk);
766 if (sk->sk_type != SOCK_SEQPACKET) { 766 if (sk->sk_type != SOCK_SEQPACKET) {
767 err = -EOPNOTSUPP; 767 err = -EOPNOTSUPP;
768 goto out; 768 goto out_release;
769 } 769 }
770 770
771 if (sk->sk_state != TCP_LISTEN) { 771 if (sk->sk_state != TCP_LISTEN) {
772 err = -EINVAL; 772 err = -EINVAL;
773 goto out; 773 goto out_release;
774 } 774 }
775 775
776 /* 776 /*
777 * The write queue this time is holding sockets ready to use 777 * The write queue this time is holding sockets ready to use
778 * hooked into the SABM we saved 778 * hooked into the SABM we saved
779 */ 779 */
780 add_wait_queue(sk->sk_sleep, &wait);
781 for (;;) { 780 for (;;) {
781 prepare_to_wait(sk->sk_sleep, &wait, TASK_INTERRUPTIBLE);
782 skb = skb_dequeue(&sk->sk_receive_queue); 782 skb = skb_dequeue(&sk->sk_receive_queue);
783 if (skb) 783 if (skb)
784 break; 784 break;
785 785
786 current->state = TASK_INTERRUPTIBLE;
787 release_sock(sk);
788 if (flags & O_NONBLOCK) { 786 if (flags & O_NONBLOCK) {
789 current->state = TASK_RUNNING; 787 err = -EWOULDBLOCK;
790 remove_wait_queue(sk->sk_sleep, &wait); 788 break;
791 return -EWOULDBLOCK;
792 } 789 }
793 if (!signal_pending(tsk)) { 790 if (!signal_pending(current)) {
791 release_sock(sk);
794 schedule(); 792 schedule();
795 lock_sock(sk); 793 lock_sock(sk);
796 continue; 794 continue;
797 } 795 }
798 current->state = TASK_RUNNING; 796 err = -ERESTARTSYS;
799 remove_wait_queue(sk->sk_sleep, &wait); 797 break;
800 return -ERESTARTSYS;
801 } 798 }
802 current->state = TASK_RUNNING; 799 finish_wait(sk->sk_sleep, &wait);
803 remove_wait_queue(sk->sk_sleep, &wait); 800 if (err)
801 goto out_release;
804 802
805 newsk = skb->sk; 803 newsk = skb->sk;
806 newsk->sk_socket = newsock; 804 newsk->sk_socket = newsock;
@@ -811,8 +809,9 @@ static int nr_accept(struct socket *sock, struct socket *newsock, int flags)
811 sk_acceptq_removed(sk); 809 sk_acceptq_removed(sk);
812 newsock->sk = newsk; 810 newsock->sk = newsk;
813 811
814out: 812out_release:
815 release_sock(sk); 813 release_sock(sk);
814
816 return err; 815 return err;
817} 816}
818 817
@@ -878,7 +877,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
878 if (frametype == NR_PROTOEXT && 877 if (frametype == NR_PROTOEXT &&
879 circuit_index == NR_PROTO_IP && circuit_id == NR_PROTO_IP) { 878 circuit_index == NR_PROTO_IP && circuit_id == NR_PROTO_IP) {
880 skb_pull(skb, NR_NETWORK_LEN + NR_TRANSPORT_LEN); 879 skb_pull(skb, NR_NETWORK_LEN + NR_TRANSPORT_LEN);
881 skb->h.raw = skb->data; 880 skb_reset_transport_header(skb);
882 881
883 return nr_rx_ip(skb, dev); 882 return nr_rx_ip(skb, dev);
884 } 883 }
@@ -904,7 +903,7 @@ int nr_rx_frame(struct sk_buff *skb, struct net_device *dev)
904 } 903 }
905 904
906 if (sk != NULL) { 905 if (sk != NULL) {
907 skb->h.raw = skb->data; 906 skb_reset_transport_header(skb);
908 907
909 if (frametype == NR_CONNACK && skb->len == 22) 908 if (frametype == NR_CONNACK && skb->len == 22)
910 nr_sk(sk)->bpqext = 1; 909 nr_sk(sk)->bpqext = 1;
@@ -1074,6 +1073,7 @@ static int nr_sendmsg(struct kiocb *iocb, struct socket *sock,
1074 goto out; 1073 goto out;
1075 1074
1076 skb_reserve(skb, size - len); 1075 skb_reserve(skb, size - len);
1076 skb_reset_transport_header(skb);
1077 1077
1078 /* 1078 /*
1079 * Push down the NET/ROM header 1079 * Push down the NET/ROM header
@@ -1094,14 +1094,12 @@ static int nr_sendmsg(struct kiocb *iocb, struct socket *sock,
1094 /* 1094 /*
1095 * Put the data on the end 1095 * Put the data on the end
1096 */ 1096 */
1097 skb_put(skb, len);
1097 1098
1098 skb->h.raw = skb_put(skb, len);
1099
1100 asmptr = skb->h.raw;
1101 SOCK_DEBUG(sk, "NET/ROM: Appending user data\n"); 1099 SOCK_DEBUG(sk, "NET/ROM: Appending user data\n");
1102 1100
1103 /* User data follows immediately after the NET/ROM transport header */ 1101 /* User data follows immediately after the NET/ROM transport header */
1104 if (memcpy_fromiovec(asmptr, msg->msg_iov, len)) { 1102 if (memcpy_fromiovec(skb_transport_header(skb), msg->msg_iov, len)) {
1105 kfree_skb(skb); 1103 kfree_skb(skb);
1106 err = -EFAULT; 1104 err = -EFAULT;
1107 goto out; 1105 goto out;
@@ -1149,7 +1147,7 @@ static int nr_recvmsg(struct kiocb *iocb, struct socket *sock,
1149 return er; 1147 return er;
1150 } 1148 }
1151 1149
1152 skb->h.raw = skb->data; 1150 skb_reset_transport_header(skb);
1153 copied = skb->len; 1151 copied = skb->len;
1154 1152
1155 if (copied > size) { 1153 if (copied > size) {
@@ -1161,7 +1159,8 @@ static int nr_recvmsg(struct kiocb *iocb, struct socket *sock,
1161 1159
1162 if (sax != NULL) { 1160 if (sax != NULL) {
1163 sax->sax25_family = AF_NETROM; 1161 sax->sax25_family = AF_NETROM;
1164 memcpy(sax->sax25_call.ax25_call, skb->data + 7, AX25_ADDR_LEN); 1162 skb_copy_from_linear_data_offset(skb, 7, sax->sax25_call.ax25_call,
1163 AX25_ADDR_LEN);
1165 } 1164 }
1166 1165
1167 msg->msg_namelen = sizeof(*sax); 1166 msg->msg_namelen = sizeof(*sax);
@@ -1209,6 +1208,12 @@ static int nr_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1209 release_sock(sk); 1208 release_sock(sk);
1210 return ret; 1209 return ret;
1211 1210
1211 case SIOCGSTAMPNS:
1212 lock_sock(sk);
1213 ret = sock_get_timestampns(sk, argp);
1214 release_sock(sk);
1215 return ret;
1216
1212 case SIOCGIFADDR: 1217 case SIOCGIFADDR:
1213 case SIOCSIFADDR: 1218 case SIOCSIFADDR:
1214 case SIOCGIFDSTADDR: 1219 case SIOCGIFDSTADDR:
diff --git a/net/netrom/nr_dev.c b/net/netrom/nr_dev.c
index 9a97ed6e6910..c7b5d930e732 100644
--- a/net/netrom/nr_dev.c
+++ b/net/netrom/nr_dev.c
@@ -56,8 +56,8 @@ int nr_rx_ip(struct sk_buff *skb, struct net_device *dev)
56 56
57 /* Spoof incoming device */ 57 /* Spoof incoming device */
58 skb->dev = dev; 58 skb->dev = dev;
59 skb->mac.raw = skb->nh.raw; 59 skb_reset_mac_header(skb);
60 skb->nh.raw = skb->data; 60 skb_reset_network_header(skb);
61 skb->pkt_type = PACKET_HOST; 61 skb->pkt_type = PACKET_HOST;
62 62
63 netif_rx(skb); 63 netif_rx(skb);
diff --git a/net/netrom/nr_in.c b/net/netrom/nr_in.c
index 5560acbaaa95..68176483617f 100644
--- a/net/netrom/nr_in.c
+++ b/net/netrom/nr_in.c
@@ -51,10 +51,12 @@ static int nr_queue_rx_frame(struct sock *sk, struct sk_buff *skb, int more)
51 if ((skbn = alloc_skb(nr->fraglen, GFP_ATOMIC)) == NULL) 51 if ((skbn = alloc_skb(nr->fraglen, GFP_ATOMIC)) == NULL)
52 return 1; 52 return 1;
53 53
54 skbn->h.raw = skbn->data; 54 skb_reset_transport_header(skbn);
55 55
56 while ((skbo = skb_dequeue(&nr->frag_queue)) != NULL) { 56 while ((skbo = skb_dequeue(&nr->frag_queue)) != NULL) {
57 memcpy(skb_put(skbn, skbo->len), skbo->data, skbo->len); 57 skb_copy_from_linear_data(skbo,
58 skb_put(skbn, skbo->len),
59 skbo->len);
58 kfree_skb(skbo); 60 kfree_skb(skbo);
59 } 61 }
60 62
diff --git a/net/netrom/nr_loopback.c b/net/netrom/nr_loopback.c
index e856ae1b360a..f324d5df4186 100644
--- a/net/netrom/nr_loopback.c
+++ b/net/netrom/nr_loopback.c
@@ -34,8 +34,8 @@ int nr_loopback_queue(struct sk_buff *skb)
34 struct sk_buff *skbn; 34 struct sk_buff *skbn;
35 35
36 if ((skbn = alloc_skb(skb->len, GFP_ATOMIC)) != NULL) { 36 if ((skbn = alloc_skb(skb->len, GFP_ATOMIC)) != NULL) {
37 memcpy(skb_put(skbn, skb->len), skb->data, skb->len); 37 skb_copy_from_linear_data(skb, skb_put(skbn, skb->len), skb->len);
38 skbn->h.raw = skbn->data; 38 skb_reset_transport_header(skbn);
39 39
40 skb_queue_tail(&loopback_queue, skbn); 40 skb_queue_tail(&loopback_queue, skbn);
41 41
diff --git a/net/netrom/nr_out.c b/net/netrom/nr_out.c
index 0cbfb611465b..e3e6c44e1890 100644
--- a/net/netrom/nr_out.c
+++ b/net/netrom/nr_out.c
@@ -40,7 +40,7 @@ void nr_output(struct sock *sk, struct sk_buff *skb)
40 40
41 if (skb->len - NR_TRANSPORT_LEN > NR_MAX_PACKET_SIZE) { 41 if (skb->len - NR_TRANSPORT_LEN > NR_MAX_PACKET_SIZE) {
42 /* Save a copy of the Transport Header */ 42 /* Save a copy of the Transport Header */
43 memcpy(transport, skb->data, NR_TRANSPORT_LEN); 43 skb_copy_from_linear_data(skb, transport, NR_TRANSPORT_LEN);
44 skb_pull(skb, NR_TRANSPORT_LEN); 44 skb_pull(skb, NR_TRANSPORT_LEN);
45 45
46 frontlen = skb_headroom(skb); 46 frontlen = skb_headroom(skb);
@@ -54,13 +54,13 @@ void nr_output(struct sock *sk, struct sk_buff *skb)
54 len = (NR_MAX_PACKET_SIZE > skb->len) ? skb->len : NR_MAX_PACKET_SIZE; 54 len = (NR_MAX_PACKET_SIZE > skb->len) ? skb->len : NR_MAX_PACKET_SIZE;
55 55
56 /* Copy the user data */ 56 /* Copy the user data */
57 memcpy(skb_put(skbn, len), skb->data, len); 57 skb_copy_from_linear_data(skb, skb_put(skbn, len), len);
58 skb_pull(skb, len); 58 skb_pull(skb, len);
59 59
60 /* Duplicate the Transport Header */ 60 /* Duplicate the Transport Header */
61 skb_push(skbn, NR_TRANSPORT_LEN); 61 skb_push(skbn, NR_TRANSPORT_LEN);
62 memcpy(skbn->data, transport, NR_TRANSPORT_LEN); 62 skb_copy_to_linear_data(skbn, transport,
63 63 NR_TRANSPORT_LEN);
64 if (skb->len > 0) 64 if (skb->len > 0)
65 skbn->data[4] |= NR_MORE_FLAG; 65 skbn->data[4] |= NR_MORE_FLAG;
66 66
diff --git a/net/netrom/nr_subr.c b/net/netrom/nr_subr.c
index 07b694d18870..04e7d0d2fd8f 100644
--- a/net/netrom/nr_subr.c
+++ b/net/netrom/nr_subr.c
@@ -226,13 +226,13 @@ void __nr_transmit_reply(struct sk_buff *skb, int mine, unsigned char cmdflags)
226 226
227 dptr = skb_put(skbn, NR_NETWORK_LEN + NR_TRANSPORT_LEN); 227 dptr = skb_put(skbn, NR_NETWORK_LEN + NR_TRANSPORT_LEN);
228 228
229 memcpy(dptr, skb->data + 7, AX25_ADDR_LEN); 229 skb_copy_from_linear_data_offset(skb, 7, dptr, AX25_ADDR_LEN);
230 dptr[6] &= ~AX25_CBIT; 230 dptr[6] &= ~AX25_CBIT;
231 dptr[6] &= ~AX25_EBIT; 231 dptr[6] &= ~AX25_EBIT;
232 dptr[6] |= AX25_SSSID_SPARE; 232 dptr[6] |= AX25_SSSID_SPARE;
233 dptr += AX25_ADDR_LEN; 233 dptr += AX25_ADDR_LEN;
234 234
235 memcpy(dptr, skb->data + 0, AX25_ADDR_LEN); 235 skb_copy_from_linear_data(skb, dptr, AX25_ADDR_LEN);
236 dptr[6] &= ~AX25_CBIT; 236 dptr[6] &= ~AX25_CBIT;
237 dptr[6] |= AX25_EBIT; 237 dptr[6] |= AX25_EBIT;
238 dptr[6] |= AX25_SSSID_SPARE; 238 dptr[6] |= AX25_SSSID_SPARE;