提交 61fbab77 编写于 作者: S stephen hemminger 提交者: David S. Miller

IPV4: use rcu to walk list of devices in IGMP

This also needs to be optimized for large number of devices.
Signed-off-by: NStephen Hemminger <shemminger@vyatta.com>
Acked-by: NEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 fa918602
...@@ -2311,7 +2311,7 @@ static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq) ...@@ -2311,7 +2311,7 @@ static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq)
struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq); struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
state->in_dev = NULL; state->in_dev = NULL;
for_each_netdev(net, state->dev) { for_each_netdev_rcu(net, state->dev) {
struct in_device *in_dev; struct in_device *in_dev;
in_dev = in_dev_get(state->dev); in_dev = in_dev_get(state->dev);
if (!in_dev) if (!in_dev)
...@@ -2361,9 +2361,9 @@ static struct ip_mc_list *igmp_mc_get_idx(struct seq_file *seq, loff_t pos) ...@@ -2361,9 +2361,9 @@ static struct ip_mc_list *igmp_mc_get_idx(struct seq_file *seq, loff_t pos)
} }
static void *igmp_mc_seq_start(struct seq_file *seq, loff_t *pos) static void *igmp_mc_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(dev_base_lock) __acquires(rcu)
{ {
read_lock(&dev_base_lock); rcu_read_lock();
return *pos ? igmp_mc_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; return *pos ? igmp_mc_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
} }
...@@ -2379,7 +2379,7 @@ static void *igmp_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -2379,7 +2379,7 @@ static void *igmp_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos)
} }
static void igmp_mc_seq_stop(struct seq_file *seq, void *v) static void igmp_mc_seq_stop(struct seq_file *seq, void *v)
__releases(dev_base_lock) __releases(rcu)
{ {
struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq); struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
if (likely(state->in_dev != NULL)) { if (likely(state->in_dev != NULL)) {
...@@ -2388,7 +2388,7 @@ static void igmp_mc_seq_stop(struct seq_file *seq, void *v) ...@@ -2388,7 +2388,7 @@ static void igmp_mc_seq_stop(struct seq_file *seq, void *v)
state->in_dev = NULL; state->in_dev = NULL;
} }
state->dev = NULL; state->dev = NULL;
read_unlock(&dev_base_lock); rcu_read_unlock();
} }
static int igmp_mc_seq_show(struct seq_file *seq, void *v) static int igmp_mc_seq_show(struct seq_file *seq, void *v)
...@@ -2462,7 +2462,7 @@ static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq) ...@@ -2462,7 +2462,7 @@ static inline struct ip_sf_list *igmp_mcf_get_first(struct seq_file *seq)
state->idev = NULL; state->idev = NULL;
state->im = NULL; state->im = NULL;
for_each_netdev(net, state->dev) { for_each_netdev_rcu(net, state->dev) {
struct in_device *idev; struct in_device *idev;
idev = in_dev_get(state->dev); idev = in_dev_get(state->dev);
if (unlikely(idev == NULL)) if (unlikely(idev == NULL))
...@@ -2528,8 +2528,9 @@ static struct ip_sf_list *igmp_mcf_get_idx(struct seq_file *seq, loff_t pos) ...@@ -2528,8 +2528,9 @@ static struct ip_sf_list *igmp_mcf_get_idx(struct seq_file *seq, loff_t pos)
} }
static void *igmp_mcf_seq_start(struct seq_file *seq, loff_t *pos) static void *igmp_mcf_seq_start(struct seq_file *seq, loff_t *pos)
__acquires(rcu)
{ {
read_lock(&dev_base_lock); rcu_read_lock();
return *pos ? igmp_mcf_get_idx(seq, *pos - 1) : SEQ_START_TOKEN; return *pos ? igmp_mcf_get_idx(seq, *pos - 1) : SEQ_START_TOKEN;
} }
...@@ -2545,6 +2546,7 @@ static void *igmp_mcf_seq_next(struct seq_file *seq, void *v, loff_t *pos) ...@@ -2545,6 +2546,7 @@ static void *igmp_mcf_seq_next(struct seq_file *seq, void *v, loff_t *pos)
} }
static void igmp_mcf_seq_stop(struct seq_file *seq, void *v) static void igmp_mcf_seq_stop(struct seq_file *seq, void *v)
__releases(rcu)
{ {
struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq); struct igmp_mcf_iter_state *state = igmp_mcf_seq_private(seq);
if (likely(state->im != NULL)) { if (likely(state->im != NULL)) {
...@@ -2557,7 +2559,7 @@ static void igmp_mcf_seq_stop(struct seq_file *seq, void *v) ...@@ -2557,7 +2559,7 @@ static void igmp_mcf_seq_stop(struct seq_file *seq, void *v)
state->idev = NULL; state->idev = NULL;
} }
state->dev = NULL; state->dev = NULL;
read_unlock(&dev_base_lock); rcu_read_unlock();
} }
static int igmp_mcf_seq_show(struct seq_file *seq, void *v) static int igmp_mcf_seq_show(struct seq_file *seq, void *v)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册