aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2009-05-28 19:43:52 -0400
committerDavid S. Miller <davem@davemloft.net>2009-05-28 19:43:52 -0400
commitbec571ec762a4cf855ad4446f833086fc154b60e (patch)
tree4ff3f63d60bd6a7735caebedf6e27c3e3a74efe4
parentb6211ae7f2e56837c6a4849316396d1535606e90 (diff)
decnet: Use SKB queue and list helpers instead of doing it by-hand.
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/decnet/af_decnet.c19
-rw-r--r--net/decnet/dn_nsp_out.c8
2 files changed, 7 insertions, 20 deletions
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 9647d911f916..bccb3887773e 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -1250,14 +1250,8 @@ static int dn_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
1250 if (skb) { 1250 if (skb) {
1251 amount = skb->len; 1251 amount = skb->len;
1252 } else { 1252 } else {
1253 skb = sk->sk_receive_queue.next; 1253 skb_queue_walk(&sk->sk_receive_queue, skb)
1254 for (;;) {
1255 if (skb ==
1256 (struct sk_buff *)&sk->sk_receive_queue)
1257 break;
1258 amount += skb->len; 1254 amount += skb->len;
1259 skb = skb->next;
1260 }
1261 } 1255 }
1262 release_sock(sk); 1256 release_sock(sk);
1263 err = put_user(amount, (int __user *)arg); 1257 err = put_user(amount, (int __user *)arg);
@@ -1644,13 +1638,13 @@ static int __dn_getsockopt(struct socket *sock, int level,int optname, char __us
1644 1638
1645static int dn_data_ready(struct sock *sk, struct sk_buff_head *q, int flags, int target) 1639static int dn_data_ready(struct sock *sk, struct sk_buff_head *q, int flags, int target)
1646{ 1640{
1647 struct sk_buff *skb = q->next; 1641 struct sk_buff *skb;
1648 int len = 0; 1642 int len = 0;
1649 1643
1650 if (flags & MSG_OOB) 1644 if (flags & MSG_OOB)
1651 return !skb_queue_empty(q) ? 1 : 0; 1645 return !skb_queue_empty(q) ? 1 : 0;
1652 1646
1653 while(skb != (struct sk_buff *)q) { 1647 skb_queue_walk(q, skb) {
1654 struct dn_skb_cb *cb = DN_SKB_CB(skb); 1648 struct dn_skb_cb *cb = DN_SKB_CB(skb);
1655 len += skb->len; 1649 len += skb->len;
1656 1650
@@ -1666,8 +1660,6 @@ static int dn_data_ready(struct sock *sk, struct sk_buff_head *q, int flags, int
1666 /* minimum data length for read exceeded */ 1660 /* minimum data length for read exceeded */
1667 if (len >= target) 1661 if (len >= target)
1668 return 1; 1662 return 1;
1669
1670 skb = skb->next;
1671 } 1663 }
1672 1664
1673 return 0; 1665 return 0;
@@ -1683,7 +1675,7 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
1683 size_t target = size > 1 ? 1 : 0; 1675 size_t target = size > 1 ? 1 : 0;
1684 size_t copied = 0; 1676 size_t copied = 0;
1685 int rv = 0; 1677 int rv = 0;
1686 struct sk_buff *skb, *nskb; 1678 struct sk_buff *skb, *n;
1687 struct dn_skb_cb *cb = NULL; 1679 struct dn_skb_cb *cb = NULL;
1688 unsigned char eor = 0; 1680 unsigned char eor = 0;
1689 long timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT); 1681 long timeo = sock_rcvtimeo(sk, flags & MSG_DONTWAIT);
@@ -1758,7 +1750,7 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
1758 finish_wait(sk->sk_sleep, &wait); 1750 finish_wait(sk->sk_sleep, &wait);
1759 } 1751 }
1760 1752
1761 for(skb = queue->next; skb != (struct sk_buff *)queue; skb = nskb) { 1753 skb_queue_walk_safe(queue, skb, n) {
1762 unsigned int chunk = skb->len; 1754 unsigned int chunk = skb->len;
1763 cb = DN_SKB_CB(skb); 1755 cb = DN_SKB_CB(skb);
1764 1756
@@ -1775,7 +1767,6 @@ static int dn_recvmsg(struct kiocb *iocb, struct socket *sock,
1775 skb_pull(skb, chunk); 1767 skb_pull(skb, chunk);
1776 1768
1777 eor = cb->nsp_flags & 0x40; 1769 eor = cb->nsp_flags & 0x40;
1778 nskb = skb->next;
1779 1770
1780 if (skb->len == 0) { 1771 if (skb->len == 0) {
1781 skb_unlink(skb, queue); 1772 skb_unlink(skb, queue);
diff --git a/net/decnet/dn_nsp_out.c b/net/decnet/dn_nsp_out.c
index 2013c25b7f5a..da04f459337e 100644
--- a/net/decnet/dn_nsp_out.c
+++ b/net/decnet/dn_nsp_out.c
@@ -382,7 +382,7 @@ int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff
382{ 382{
383 struct dn_skb_cb *cb = DN_SKB_CB(skb); 383 struct dn_skb_cb *cb = DN_SKB_CB(skb);
384 struct dn_scp *scp = DN_SK(sk); 384 struct dn_scp *scp = DN_SK(sk);
385 struct sk_buff *skb2, *list, *ack = NULL; 385 struct sk_buff *skb2, *n, *ack = NULL;
386 int wakeup = 0; 386 int wakeup = 0;
387 int try_retrans = 0; 387 int try_retrans = 0;
388 unsigned long reftime = cb->stamp; 388 unsigned long reftime = cb->stamp;
@@ -390,9 +390,7 @@ int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff
390 unsigned short xmit_count; 390 unsigned short xmit_count;
391 unsigned short segnum; 391 unsigned short segnum;
392 392
393 skb2 = q->next; 393 skb_queue_walk_safe(q, skb2, n) {
394 list = (struct sk_buff *)q;
395 while(list != skb2) {
396 struct dn_skb_cb *cb2 = DN_SKB_CB(skb2); 394 struct dn_skb_cb *cb2 = DN_SKB_CB(skb2);
397 395
398 if (dn_before_or_equal(cb2->segnum, acknum)) 396 if (dn_before_or_equal(cb2->segnum, acknum))
@@ -400,8 +398,6 @@ int dn_nsp_check_xmit_queue(struct sock *sk, struct sk_buff *skb, struct sk_buff
400 398
401 /* printk(KERN_DEBUG "ack: %s %04x %04x\n", ack ? "ACK" : "SKIP", (int)cb2->segnum, (int)acknum); */ 399 /* printk(KERN_DEBUG "ack: %s %04x %04x\n", ack ? "ACK" : "SKIP", (int)cb2->segnum, (int)acknum); */
402 400
403 skb2 = skb2->next;
404
405 if (ack == NULL) 401 if (ack == NULL)
406 continue; 402 continue;
407 403