2274}
2275
2276#if defined(CONFIG_PROC_FS)
2277struct igmp_mc_iter_state {
2278 struct net_device *dev;
2279 struct in_device *in_dev;
2280};
2281
2282#define igmp_mc_seq_private(seq) ((struct igmp_mc_iter_state *)(seq)->private)
2283
2284static inline struct ip_mc_list *igmp_mc_get_first(struct seq_file *seq)
2285{
2286 struct ip_mc_list *im = NULL;
2287 struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
2288
2289 state->in_dev = NULL;
2290 for_each_netdev(&init_net, state->dev) {
2291 struct in_device *in_dev;
2292 in_dev = in_dev_get(state->dev);
2293 if (!in_dev)
2294 continue;
2295 read_lock(&in_dev->mc_list_lock);
2296 im = in_dev->mc_list;
2297 if (im) {
2298 state->in_dev = in_dev;
2299 break;
2300 }
2301 read_unlock(&in_dev->mc_list_lock);
2302 in_dev_put(in_dev);
2303 }
2304 return im;
2305}
2306
2307static struct ip_mc_list *igmp_mc_get_next(struct seq_file *seq, struct ip_mc_list *im)
2308{
2309 struct igmp_mc_iter_state *state = igmp_mc_seq_private(seq);
2310 im = im->next;
2311 while (!im) {
2312 if (likely(state->in_dev != NULL)) {
2313 read_unlock(&state->in_dev->mc_list_lock);
2314 in_dev_put(state->in_dev);