aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2007-09-16 19:24:44 -0400
committerDavid S. Miller <davem@sunset.davemloft.net>2007-10-10 19:51:24 -0400
commit0cfad07555312468296ea3bbbcdf99038f58678b (patch)
treea95c432bcafaf22e965dcaf27bfd4a61723d1d64 /net
parent007e3936bdaaa012483c9fe06ca71c272458c710 (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')
-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 1b9c32d79917..739fbad15c6a 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -1320,7 +1320,7 @@ static void rtnetlink_rcv(struct sock *sk, int len)
1320 1320
1321 do { 1321 do {
1322 mutex_lock(&rtnl_mutex); 1322 mutex_lock(&rtnl_mutex);
1323 netlink_run_queue(sk, &qlen, &rtnetlink_rcv_msg); 1323 qlen = netlink_run_queue(sk, qlen, &rtnetlink_rcv_msg);
1324 mutex_unlock(&rtnl_mutex); 1324 mutex_unlock(&rtnl_mutex);
1325 1325
1326 netdev_run_todo(); 1326 netdev_run_todo();
diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
index 031cc4856b49..b04a6ee5a9a1 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)
845 845
846 do { 846 do {
847 mutex_lock(&inet_diag_mutex); 847 mutex_lock(&inet_diag_mutex);
848 netlink_run_queue(sk, &qlen, &inet_diag_rcv_msg); 848 qlen = netlink_run_queue(sk, qlen, &inet_diag_rcv_msg);
849 mutex_unlock(&inet_diag_mutex); 849 mutex_unlock(&inet_diag_mutex);
850 } while (qlen); 850 } while (qlen);
851} 851}
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index fa974e8e0ce6..4aa56e7ff156 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -248,7 +248,7 @@ static void nfnetlink_rcv(struct sock *sk, int len)
248 do { 248 do {
249 if (nfnl_trylock()) 249 if (nfnl_trylock())
250 return; 250 return;
251 netlink_run_queue(sk, &qlen, nfnetlink_rcv_msg); 251 qlen = netlink_run_queue(sk, qlen, nfnetlink_rcv_msg);
252 __nfnl_unlock(); 252 __nfnl_unlock();
253 } while (qlen); 253 } while (qlen);
254} 254}
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 */
1649void netlink_run_queue(struct sock *sk, unsigned int *qlen, 1649unsigned 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}
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c
index 1f8e7c22ddbd..8e10e9098a83 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)
1887 1887
1888 do { 1888 do {
1889 mutex_lock(&xfrm_cfg_mutex); 1889 mutex_lock(&xfrm_cfg_mutex);
1890 netlink_run_queue(sk, &qlen, &xfrm_user_rcv_msg); 1890 qlen = netlink_run_queue(sk, qlen, &xfrm_user_rcv_msg);
1891 mutex_unlock(&xfrm_cfg_mutex); 1891 mutex_unlock(&xfrm_cfg_mutex);
1892 1892
1893 } while (qlen); 1893 } while (qlen);