mirror of
https://github.com/adulau/aha.git
synced 2024-12-28 19:56:18 +00:00
list_for_each_rcu must die: networking
All uses of list_for_each_rcu() can be profitably replaced by the easier-to-use list_for_each_entry_rcu(). This patch makes this change for networking, in preparation for removing the list_for_each_rcu() API entirely. Acked-by: David S. Miller <davem@davemloft.net> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
2fc9c4e18f
commit
696adfe84c
3 changed files with 7 additions and 15 deletions
|
@ -31,11 +31,9 @@ static struct llc_sap *snap_sap;
|
||||||
*/
|
*/
|
||||||
static struct datalink_proto *find_snap_client(unsigned char *desc)
|
static struct datalink_proto *find_snap_client(unsigned char *desc)
|
||||||
{
|
{
|
||||||
struct list_head *entry;
|
|
||||||
struct datalink_proto *proto = NULL, *p;
|
struct datalink_proto *proto = NULL, *p;
|
||||||
|
|
||||||
list_for_each_rcu(entry, &snap_list) {
|
list_for_each_entry_rcu(p, &snap_list, node) {
|
||||||
p = list_entry(entry, struct datalink_proto, node);
|
|
||||||
if (!memcmp(p->type, desc, 5)) {
|
if (!memcmp(p->type, desc, 5)) {
|
||||||
proto = p;
|
proto = p;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -264,7 +264,6 @@ static inline int inet_netns_ok(struct net *net, int protocol)
|
||||||
static int inet_create(struct net *net, struct socket *sock, int protocol)
|
static int inet_create(struct net *net, struct socket *sock, int protocol)
|
||||||
{
|
{
|
||||||
struct sock *sk;
|
struct sock *sk;
|
||||||
struct list_head *p;
|
|
||||||
struct inet_protosw *answer;
|
struct inet_protosw *answer;
|
||||||
struct inet_sock *inet;
|
struct inet_sock *inet;
|
||||||
struct proto *answer_prot;
|
struct proto *answer_prot;
|
||||||
|
@ -281,13 +280,12 @@ static int inet_create(struct net *net, struct socket *sock, int protocol)
|
||||||
sock->state = SS_UNCONNECTED;
|
sock->state = SS_UNCONNECTED;
|
||||||
|
|
||||||
/* Look for the requested type/protocol pair. */
|
/* Look for the requested type/protocol pair. */
|
||||||
answer = NULL;
|
|
||||||
lookup_protocol:
|
lookup_protocol:
|
||||||
err = -ESOCKTNOSUPPORT;
|
err = -ESOCKTNOSUPPORT;
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
list_for_each_rcu(p, &inetsw[sock->type]) {
|
list_for_each_entry_rcu(answer, &inetsw[sock->type], list) {
|
||||||
answer = list_entry(p, struct inet_protosw, list);
|
|
||||||
|
|
||||||
|
err = 0;
|
||||||
/* Check the non-wild match. */
|
/* Check the non-wild match. */
|
||||||
if (protocol == answer->protocol) {
|
if (protocol == answer->protocol) {
|
||||||
if (protocol != IPPROTO_IP)
|
if (protocol != IPPROTO_IP)
|
||||||
|
@ -302,10 +300,9 @@ lookup_protocol:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
err = -EPROTONOSUPPORT;
|
err = -EPROTONOSUPPORT;
|
||||||
answer = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unlikely(answer == NULL)) {
|
if (unlikely(err)) {
|
||||||
if (try_loading_module < 2) {
|
if (try_loading_module < 2) {
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -83,7 +83,6 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol)
|
||||||
struct inet_sock *inet;
|
struct inet_sock *inet;
|
||||||
struct ipv6_pinfo *np;
|
struct ipv6_pinfo *np;
|
||||||
struct sock *sk;
|
struct sock *sk;
|
||||||
struct list_head *p;
|
|
||||||
struct inet_protosw *answer;
|
struct inet_protosw *answer;
|
||||||
struct proto *answer_prot;
|
struct proto *answer_prot;
|
||||||
unsigned char answer_flags;
|
unsigned char answer_flags;
|
||||||
|
@ -97,13 +96,12 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol)
|
||||||
build_ehash_secret();
|
build_ehash_secret();
|
||||||
|
|
||||||
/* Look for the requested type/protocol pair. */
|
/* Look for the requested type/protocol pair. */
|
||||||
answer = NULL;
|
|
||||||
lookup_protocol:
|
lookup_protocol:
|
||||||
err = -ESOCKTNOSUPPORT;
|
err = -ESOCKTNOSUPPORT;
|
||||||
rcu_read_lock();
|
rcu_read_lock();
|
||||||
list_for_each_rcu(p, &inetsw6[sock->type]) {
|
list_for_each_entry_rcu(answer, &inetsw6[sock->type], list) {
|
||||||
answer = list_entry(p, struct inet_protosw, list);
|
|
||||||
|
|
||||||
|
err = 0;
|
||||||
/* Check the non-wild match. */
|
/* Check the non-wild match. */
|
||||||
if (protocol == answer->protocol) {
|
if (protocol == answer->protocol) {
|
||||||
if (protocol != IPPROTO_IP)
|
if (protocol != IPPROTO_IP)
|
||||||
|
@ -118,10 +116,9 @@ lookup_protocol:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
err = -EPROTONOSUPPORT;
|
err = -EPROTONOSUPPORT;
|
||||||
answer = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!answer) {
|
if (err) {
|
||||||
if (try_loading_module < 2) {
|
if (try_loading_module < 2) {
|
||||||
rcu_read_unlock();
|
rcu_read_unlock();
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue