Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 202703
b: refs/heads/master
c: 592fcb9
h: refs/heads/master
i:
  202701: 61cc0e3
  202699: 1d29053
  202695: 5487343
  202687: 79eb433
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Jun 11, 2010
1 parent 4ccb758 commit 00fe5ec
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 96b52e61be1ad4d4f8de39b9deaf253da804ea3b
refs/heads/master: 592fcb9dfafaa02dd0edc207bf5d3a0ee7a1f8df
5 changes: 4 additions & 1 deletion trunk/include/net/ip.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ struct ipcm_cookie {
struct ip_ra_chain {
struct ip_ra_chain *next;
struct sock *sk;
void (*destructor)(struct sock *);
union {
void (*destructor)(struct sock *);
struct sock *saved_sk;
};
struct rcu_head rcu;
};

Expand Down
19 changes: 15 additions & 4 deletions trunk/net/ipv4/ip_sockglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,13 @@ int ip_cmsg_send(struct net *net, struct msghdr *msg, struct ipcm_cookie *ipc)
struct ip_ra_chain *ip_ra_chain;
static DEFINE_SPINLOCK(ip_ra_lock);

static void ip_ra_free_rcu(struct rcu_head *head)

static void ip_ra_destroy_rcu(struct rcu_head *head)
{
kfree(container_of(head, struct ip_ra_chain, rcu));
struct ip_ra_chain *ra = container_of(head, struct ip_ra_chain, rcu);

sock_put(ra->saved_sk);
kfree(ra);
}

int ip_ra_control(struct sock *sk, unsigned char on,
Expand All @@ -264,13 +268,20 @@ int ip_ra_control(struct sock *sk, unsigned char on,
kfree(new_ra);
return -EADDRINUSE;
}
/* dont let ip_call_ra_chain() use sk again */
ra->sk = NULL;
rcu_assign_pointer(*rap, ra->next);
spin_unlock_bh(&ip_ra_lock);

if (ra->destructor)
ra->destructor(sk);
sock_put(sk);
call_rcu(&ra->rcu, ip_ra_free_rcu);
/*
* Delay sock_put(sk) and kfree(ra) after one rcu grace
* period. This guarantee ip_call_ra_chain() dont need
* to mess with socket refcounts.
*/
ra->saved_sk = sk;
call_rcu(&ra->rcu, ip_ra_destroy_rcu);
return 0;
}
}
Expand Down

0 comments on commit 00fe5ec

Please sign in to comment.