diff options
author | Herbert Xu <herbert@gondor.apana.org.au> | 2007-09-16 19:24:44 -0400 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-10-10 19:51:24 -0400 |
commit | 0cfad07555312468296ea3bbbcdf99038f58678b (patch) | |
tree | a95c432bcafaf22e965dcaf27bfd4a61723d1d64 /net/netlink | |
parent | 007e3936bdaaa012483c9fe06ca71c272458c710 (diff) |
[NETLINK]: Avoid pointer in netlink_run_queue
I was looking at Patrick's fix to inet_diag and it occured
to me that we're using a pointer argument to return values
unnecessarily in netlink_run_queue. Changing it to return
the value will allow the compiler to generate better code
since the value won't have to be memory-backed.
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/netlink')
-rw-r--r-- | net/netlink/af_netlink.c | 18 | ||||
-rw-r--r-- | net/netlink/genetlink.c | 2 |
2 files changed, 11 insertions, 9 deletions
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index dc9f8c2ab1d5..c68888b25756 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
@@ -1629,7 +1629,7 @@ skip: | |||
1629 | /** | 1629 | /** |
1630 | * nelink_run_queue - Process netlink receive queue. | 1630 | * nelink_run_queue - Process netlink receive queue. |
1631 | * @sk: Netlink socket containing the queue | 1631 | * @sk: Netlink socket containing the queue |
1632 | * @qlen: Place to store queue length upon entry | 1632 | * @qlen: Initial queue length |
1633 | * @cb: Callback function invoked for each netlink message found | 1633 | * @cb: Callback function invoked for each netlink message found |
1634 | * | 1634 | * |
1635 | * Processes as much as there was in the queue upon entry and invokes | 1635 | * Processes as much as there was in the queue upon entry and invokes |
@@ -1639,35 +1639,37 @@ skip: | |||
1639 | * returns with a qlen != 0. | 1639 | * returns with a qlen != 0. |
1640 | * | 1640 | * |
1641 | * qlen must be initialized to 0 before the initial entry, afterwards | 1641 | * qlen must be initialized to 0 before the initial entry, afterwards |
1642 | * the function may be called repeatedly until qlen reaches 0. | 1642 | * the function may be called repeatedly until the returned qlen is 0. |
1643 | * | 1643 | * |
1644 | * The callback function may return -EINTR to signal that processing | 1644 | * The callback function may return -EINTR to signal that processing |
1645 | * of netlink messages shall be interrupted. In this case the message | 1645 | * of netlink messages shall be interrupted. In this case the message |
1646 | * currently being processed will NOT be requeued onto the receive | 1646 | * currently being processed will NOT be requeued onto the receive |
1647 | * queue. | 1647 | * queue. |
1648 | */ | 1648 | */ |
1649 | void netlink_run_queue(struct sock *sk, unsigned int *qlen, | 1649 | unsigned int netlink_run_queue(struct sock *sk, unsigned int qlen, |
1650 | int (*cb)(struct sk_buff *, struct nlmsghdr *)) | 1650 | int (*cb)(struct sk_buff *, struct nlmsghdr *)) |
1651 | { | 1651 | { |
1652 | struct sk_buff *skb; | 1652 | struct sk_buff *skb; |
1653 | 1653 | ||
1654 | if (!*qlen || *qlen > skb_queue_len(&sk->sk_receive_queue)) | 1654 | if (!qlen || qlen > skb_queue_len(&sk->sk_receive_queue)) |
1655 | *qlen = skb_queue_len(&sk->sk_receive_queue); | 1655 | qlen = skb_queue_len(&sk->sk_receive_queue); |
1656 | 1656 | ||
1657 | for (; *qlen; (*qlen)--) { | 1657 | for (; qlen; qlen--) { |
1658 | skb = skb_dequeue(&sk->sk_receive_queue); | 1658 | skb = skb_dequeue(&sk->sk_receive_queue); |
1659 | if (netlink_rcv_skb(skb, cb)) { | 1659 | if (netlink_rcv_skb(skb, cb)) { |
1660 | if (skb->len) | 1660 | if (skb->len) |
1661 | skb_queue_head(&sk->sk_receive_queue, skb); | 1661 | skb_queue_head(&sk->sk_receive_queue, skb); |
1662 | else { | 1662 | else { |
1663 | kfree_skb(skb); | 1663 | kfree_skb(skb); |
1664 | (*qlen)--; | 1664 | qlen--; |
1665 | } | 1665 | } |
1666 | break; | 1666 | break; |
1667 | } | 1667 | } |
1668 | 1668 | ||
1669 | kfree_skb(skb); | 1669 | kfree_skb(skb); |
1670 | } | 1670 | } |
1671 | |||
1672 | return qlen; | ||
1671 | } | 1673 | } |
1672 | 1674 | ||
1673 | /** | 1675 | /** |
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index af8fe26815fa..07ef5d204a0f 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
@@ -485,7 +485,7 @@ static void genl_rcv(struct sock *sk, int len) | |||
485 | do { | 485 | do { |
486 | if (genl_trylock()) | 486 | if (genl_trylock()) |
487 | return; | 487 | return; |
488 | netlink_run_queue(sk, &qlen, genl_rcv_msg); | 488 | qlen = netlink_run_queue(sk, qlen, genl_rcv_msg); |
489 | genl_unlock(); | 489 | genl_unlock(); |
490 | } while (qlen && genl_sock && genl_sock->sk_receive_queue.qlen); | 490 | } while (qlen && genl_sock && genl_sock->sk_receive_queue.qlen); |
491 | } | 491 | } |