aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-09-16 16:24:44 -0700
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 16:51:24 -0700
commit0cfad07555312468296ea3bbbcdf99038f58678b (patch)
treea95c432bcafaf22e965dcaf27bfd4a61723d1d64 /net
parent007e3936bdaaa012483c9fe06ca71c272458c710 (diff)
downloadkernel_samsung_aries-0cfad07555312468296ea3bbbcdf99038f58678b.zip
kernel_samsung_aries-0cfad07555312468296ea3bbbcdf99038f58678b.tar.gz
kernel_samsung_aries-0cfad07555312468296ea3bbbcdf99038f58678b.tar.bz2
[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')
-rw-r--r--net/core/rtnetlink.c2
-rw-r--r--net/ipv4/inet_diag.c2
-rw-r--r--net/netfilter/nfnetlink.c2
-rw-r--r--net/netlink/af_netlink.c18
-rw-r--r--net/netlink/genetlink.c2
-rw-r--r--net/xfrm/xfrm_user.c2
6 files changed, 15 insertions, 13 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 1b9c32d..739fbad 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1320,7 +1320,7 @@ static void rtnetlink_rcv(struct sock *sk, int len)
do {
mutex_lock(&rtnl_mutex);
- netlink_run_queue(sk, &qlen, &rtnetlink_rcv_msg);
+ qlen = netlink_run_queue(sk, qlen, &rtnetlink_rcv_msg);
mutex_unlock(&rtnl_mutex);
netdev_run_todo();
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 031cc48..b04a6ee 100644
--- a/net/ipv4/inet_diag.c
+++ b/net/ipv4/inet_diag.c
@@ -845,7 +845,7 @@ static void inet_diag_rcv(struct sock *sk, int len)
do {
mutex_lock(&inet_diag_mutex);
- netlink_run_queue(sk, &qlen, &inet_diag_rcv_msg);
+ qlen = netlink_run_queue(sk, qlen, &inet_diag_rcv_msg);
mutex_unlock(&inet_diag_mutex);
} while (qlen);
}
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index fa974e8..4aa56e7f 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -248,7 +248,7 @@ static void nfnetlink_rcv(struct sock *sk, int len)
do {
if (nfnl_trylock())
return;
- netlink_run_queue(sk, &qlen, nfnetlink_rcv_msg);
+ qlen = netlink_run_queue(sk, qlen, nfnetlink_rcv_msg);
__nfnl_unlock();
} while (qlen);
}
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index dc9f8c2..c68888b 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1629,7 +1629,7 @@ skip:
/**
* nelink_run_queue - Process netlink receive queue.
* @sk: Netlink socket containing the queue
- * @qlen: Place to store queue length upon entry
+ * @qlen: Initial queue length
* @cb: Callback function invoked for each netlink message found
*
* Processes as much as there was in the queue upon entry and invokes
@@ -1639,35 +1639,37 @@ skip:
* returns with a qlen != 0.
*
* qlen must be initialized to 0 before the initial entry, afterwards
- * the function may be called repeatedly until qlen reaches 0.
+ * the function may be called repeatedly until the returned qlen is 0.
*
* The callback function may return -EINTR to signal that processing
* of netlink messages shall be interrupted. In this case the message
* currently being processed will NOT be requeued onto the receive
* queue.
*/
-void netlink_run_queue(struct sock *sk, unsigned int *qlen,
- int (*cb)(struct sk_buff *, struct nlmsghdr *))
+unsigned int netlink_run_queue(struct sock *sk, unsigned int qlen,
+ int (*cb)(struct sk_buff *, struct nlmsghdr *))
{
struct sk_buff *skb;
- if (!*qlen || *qlen > skb_queue_len(&sk->sk_receive_queue))
- *qlen = skb_queue_len(&sk->sk_receive_queue);
+ if (!qlen || qlen > skb_queue_len(&sk->sk_receive_queue))
+ qlen = skb_queue_len(&sk->sk_receive_queue);
- for (; *qlen; (*qlen)--) {
+ for (; qlen; qlen--) {
skb = skb_dequeue(&sk->sk_receive_queue);
if (netlink_rcv_skb(skb, cb)) {
if (skb->len)
skb_queue_head(&sk->sk_receive_queue, skb);
else {
kfree_skb(skb);
- (*qlen)--;
+ qlen--;
}
break;
}
kfree_skb(skb);
}
+
+ return qlen;
}
/**
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index af8fe26..07ef5d2 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -485,7 +485,7 @@ static void genl_rcv(struct sock *sk, int len)
do {
if (genl_trylock())
return;
- netlink_run_queue(sk, &qlen, genl_rcv_msg);
+ qlen = netlink_run_queue(sk, qlen, genl_rcv_msg);
genl_unlock();
} while (qlen && genl_sock && genl_sock->sk_receive_queue.qlen);
}
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 1f8e7c2..8e10e90 100644
--- a/net/xfrm/xfrm_user.c
+++ b/net/xfrm/xfrm_user.c
@@ -1887,7 +1887,7 @@ static void xfrm_netlink_rcv(struct sock *sk, int len)
do {
mutex_lock(&xfrm_cfg_mutex);
- netlink_run_queue(sk, &qlen, &xfrm_user_rcv_msg);
+ qlen = netlink_run_queue(sk, qlen, &xfrm_user_rcv_msg);
mutex_unlock(&xfrm_cfg_mutex);
} while (qlen);