diff options
Diffstat (limited to 'net/phonet/pep.c')
-rw-r--r-- | net/phonet/pep.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/net/phonet/pep.c b/net/phonet/pep.c index 5f32d217535b..b6356f3832f6 100644 --- a/net/phonet/pep.c +++ b/net/phonet/pep.c | |||
@@ -360,8 +360,6 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb) | |||
360 | err = sock_queue_rcv_skb(sk, skb); | 360 | err = sock_queue_rcv_skb(sk, skb); |
361 | if (!err) | 361 | if (!err) |
362 | return 0; | 362 | return 0; |
363 | if (err == -ENOMEM) | ||
364 | atomic_inc(&sk->sk_drops); | ||
365 | break; | 363 | break; |
366 | } | 364 | } |
367 | 365 | ||
@@ -716,8 +714,8 @@ static int pep_ioctl(struct sock *sk, int cmd, unsigned long arg) | |||
716 | return -EINVAL; | 714 | return -EINVAL; |
717 | 715 | ||
718 | lock_sock(sk); | 716 | lock_sock(sk); |
719 | if (sock_flag(sk, SOCK_URGINLINE) | 717 | if (sock_flag(sk, SOCK_URGINLINE) && |
720 | && !skb_queue_empty(&pn->ctrlreq_queue)) | 718 | !skb_queue_empty(&pn->ctrlreq_queue)) |
721 | answ = skb_peek(&pn->ctrlreq_queue)->len; | 719 | answ = skb_peek(&pn->ctrlreq_queue)->len; |
722 | else if (!skb_queue_empty(&sk->sk_receive_queue)) | 720 | else if (!skb_queue_empty(&sk->sk_receive_queue)) |
723 | answ = skb_peek(&sk->sk_receive_queue)->len; | 721 | answ = skb_peek(&sk->sk_receive_queue)->len; |
@@ -845,7 +843,7 @@ static int pep_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
845 | struct msghdr *msg, size_t len) | 843 | struct msghdr *msg, size_t len) |
846 | { | 844 | { |
847 | struct pep_sock *pn = pep_sk(sk); | 845 | struct pep_sock *pn = pep_sk(sk); |
848 | struct sk_buff *skb = NULL; | 846 | struct sk_buff *skb; |
849 | long timeo; | 847 | long timeo; |
850 | int flags = msg->msg_flags; | 848 | int flags = msg->msg_flags; |
851 | int err, done; | 849 | int err, done; |
@@ -853,6 +851,16 @@ static int pep_sendmsg(struct kiocb *iocb, struct sock *sk, | |||
853 | if (msg->msg_flags & MSG_OOB || !(msg->msg_flags & MSG_EOR)) | 851 | if (msg->msg_flags & MSG_OOB || !(msg->msg_flags & MSG_EOR)) |
854 | return -EOPNOTSUPP; | 852 | return -EOPNOTSUPP; |
855 | 853 | ||
854 | skb = sock_alloc_send_skb(sk, MAX_PNPIPE_HEADER + len, | ||
855 | flags & MSG_DONTWAIT, &err); | ||
856 | if (!skb) | ||
857 | return -ENOBUFS; | ||
858 | |||
859 | skb_reserve(skb, MAX_PHONET_HEADER + 3); | ||
860 | err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); | ||
861 | if (err < 0) | ||
862 | goto outfree; | ||
863 | |||
856 | lock_sock(sk); | 864 | lock_sock(sk); |
857 | timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); | 865 | timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); |
858 | if ((1 << sk->sk_state) & (TCPF_LISTEN|TCPF_CLOSE)) { | 866 | if ((1 << sk->sk_state) & (TCPF_LISTEN|TCPF_CLOSE)) { |
@@ -896,28 +904,13 @@ disabled: | |||
896 | goto disabled; | 904 | goto disabled; |
897 | } | 905 | } |
898 | 906 | ||
899 | if (!skb) { | ||
900 | skb = sock_alloc_send_skb(sk, MAX_PNPIPE_HEADER + len, | ||
901 | flags & MSG_DONTWAIT, &err); | ||
902 | if (skb == NULL) | ||
903 | goto out; | ||
904 | skb_reserve(skb, MAX_PHONET_HEADER + 3); | ||
905 | |||
906 | if (sk->sk_state != TCP_ESTABLISHED || | ||
907 | !atomic_read(&pn->tx_credits)) | ||
908 | goto disabled; /* sock_alloc_send_skb might sleep */ | ||
909 | } | ||
910 | |||
911 | err = memcpy_fromiovec(skb_put(skb, len), msg->msg_iov, len); | ||
912 | if (err < 0) | ||
913 | goto out; | ||
914 | |||
915 | err = pipe_skb_send(sk, skb); | 907 | err = pipe_skb_send(sk, skb); |
916 | if (err >= 0) | 908 | if (err >= 0) |
917 | err = len; /* success! */ | 909 | err = len; /* success! */ |
918 | skb = NULL; | 910 | skb = NULL; |
919 | out: | 911 | out: |
920 | release_sock(sk); | 912 | release_sock(sk); |
913 | outfree: | ||
921 | kfree_skb(skb); | 914 | kfree_skb(skb); |
922 | return err; | 915 | return err; |
923 | } | 916 | } |