aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McHardy <kaber@trash.net>2007-11-07 05:42:09 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2007-11-07 07:15:12 -0500
commitc3d8d1e30cace31fed6186a4b8c6b1401836d89c (patch)
tree7122fccf27aa337438123071f3cb07999429de9e
parent230140cffa7feae90ad50bf259db1fa07674f3a7 (diff)
[NETLINK]: Fix unicast timeouts
Commit ed6dcf4a in the history.git tree broke netlink_unicast timeouts by moving the schedule_timeout() call to a new function that doesn't propagate the remaining timeout back to the caller. This means on each retry we start with the full timeout again. ipc/mqueue.c seems to actually want to wait indefinitely so this behaviour is retained. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/linux/netlink.h2
-rw-r--r--ipc/mqueue.c6
-rw-r--r--net/netlink/af_netlink.c10
3 files changed, 10 insertions, 8 deletions
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index 7c1f3b1d2ee5..d5bfaba595c7 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -192,7 +192,7 @@ extern int netlink_unregister_notifier(struct notifier_block *nb);
192/* finegrained unicast helpers: */ 192/* finegrained unicast helpers: */
193struct sock *netlink_getsockbyfilp(struct file *filp); 193struct sock *netlink_getsockbyfilp(struct file *filp);
194int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock, 194int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock,
195 long timeo, struct sock *ssk); 195 long *timeo, struct sock *ssk);
196void netlink_detachskb(struct sock *sk, struct sk_buff *skb); 196void netlink_detachskb(struct sock *sk, struct sk_buff *skb);
197int netlink_sendskb(struct sock *sk, struct sk_buff *skb); 197int netlink_sendskb(struct sock *sk, struct sk_buff *skb);
198 198
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index bfa274ba9ed4..1e04cd464af9 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -1010,6 +1010,8 @@ asmlinkage long sys_mq_notify(mqd_t mqdes,
1010 return -EINVAL; 1010 return -EINVAL;
1011 } 1011 }
1012 if (notification.sigev_notify == SIGEV_THREAD) { 1012 if (notification.sigev_notify == SIGEV_THREAD) {
1013 long timeo;
1014
1013 /* create the notify skb */ 1015 /* create the notify skb */
1014 nc = alloc_skb(NOTIFY_COOKIE_LEN, GFP_KERNEL); 1016 nc = alloc_skb(NOTIFY_COOKIE_LEN, GFP_KERNEL);
1015 ret = -ENOMEM; 1017 ret = -ENOMEM;
@@ -1038,8 +1040,8 @@ retry:
1038 goto out; 1040 goto out;
1039 } 1041 }
1040 1042
1041 ret = netlink_attachskb(sock, nc, 0, 1043 timeo = MAX_SCHEDULE_TIMEOUT;
1042 MAX_SCHEDULE_TIMEOUT, NULL); 1044 ret = netlink_attachskb(sock, nc, 0, &timeo, NULL);
1043 if (ret == 1) 1045 if (ret == 1)
1044 goto retry; 1046 goto retry;
1045 if (ret) { 1047 if (ret) {
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 260171255576..415c97236f63 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -752,7 +752,7 @@ struct sock *netlink_getsockbyfilp(struct file *filp)
752 * 1: repeat lookup - reference dropped while waiting for socket memory. 752 * 1: repeat lookup - reference dropped while waiting for socket memory.
753 */ 753 */
754int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock, 754int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock,
755 long timeo, struct sock *ssk) 755 long *timeo, struct sock *ssk)
756{ 756{
757 struct netlink_sock *nlk; 757 struct netlink_sock *nlk;
758 758
@@ -761,7 +761,7 @@ int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock,
761 if (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf || 761 if (atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf ||
762 test_bit(0, &nlk->state)) { 762 test_bit(0, &nlk->state)) {
763 DECLARE_WAITQUEUE(wait, current); 763 DECLARE_WAITQUEUE(wait, current);
764 if (!timeo) { 764 if (!*timeo) {
765 if (!ssk || netlink_is_kernel(ssk)) 765 if (!ssk || netlink_is_kernel(ssk))
766 netlink_overrun(sk); 766 netlink_overrun(sk);
767 sock_put(sk); 767 sock_put(sk);
@@ -775,7 +775,7 @@ int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock,
775 if ((atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf || 775 if ((atomic_read(&sk->sk_rmem_alloc) > sk->sk_rcvbuf ||
776 test_bit(0, &nlk->state)) && 776 test_bit(0, &nlk->state)) &&
777 !sock_flag(sk, SOCK_DEAD)) 777 !sock_flag(sk, SOCK_DEAD))
778 timeo = schedule_timeout(timeo); 778 *timeo = schedule_timeout(*timeo);
779 779
780 __set_current_state(TASK_RUNNING); 780 __set_current_state(TASK_RUNNING);
781 remove_wait_queue(&nlk->wait, &wait); 781 remove_wait_queue(&nlk->wait, &wait);
@@ -783,7 +783,7 @@ int netlink_attachskb(struct sock *sk, struct sk_buff *skb, int nonblock,
783 783
784 if (signal_pending(current)) { 784 if (signal_pending(current)) {
785 kfree_skb(skb); 785 kfree_skb(skb);
786 return sock_intr_errno(timeo); 786 return sock_intr_errno(*timeo);
787 } 787 }
788 return 1; 788 return 1;
789 } 789 }
@@ -877,7 +877,7 @@ retry:
877 if (netlink_is_kernel(sk)) 877 if (netlink_is_kernel(sk))
878 return netlink_unicast_kernel(sk, skb); 878 return netlink_unicast_kernel(sk, skb);
879 879
880 err = netlink_attachskb(sk, skb, nonblock, timeo, ssk); 880 err = netlink_attachskb(sk, skb, nonblock, &timeo, ssk);
881 if (err == 1) 881 if (err == 1)
882 goto retry; 882 goto retry;
883 if (err) 883 if (err)