Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[NET]: Use existing device list walker for /proc/dev_mcast.

The seq_file_operations' dev_mc_seq_xxx callbacks do the same thing as
the dev_seq_xxx ones do, but skip the SEQ_START_TOKEN.

So use the existing exported dev_seq_xxx calls and handle the
SEQ_START_TOKEN in the dev_mc_seq_show().

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Pavel Emelyanov and committed by
David S. Miller
95a36358 fd80eb94

+6 -31
+6 -31
net/core/dev_mcast.c
··· 156 156 EXPORT_SYMBOL(dev_mc_unsync); 157 157 158 158 #ifdef CONFIG_PROC_FS 159 - static void *dev_mc_seq_start(struct seq_file *seq, loff_t *pos) 160 - __acquires(dev_base_lock) 161 - { 162 - struct net *net = seq_file_net(seq); 163 - struct net_device *dev; 164 - loff_t off = 0; 165 - 166 - read_lock(&dev_base_lock); 167 - for_each_netdev(net, dev) { 168 - if (off++ == *pos) 169 - return dev; 170 - } 171 - return NULL; 172 - } 173 - 174 - static void *dev_mc_seq_next(struct seq_file *seq, void *v, loff_t *pos) 175 - { 176 - ++*pos; 177 - return next_net_device((struct net_device *)v); 178 - } 179 - 180 - static void dev_mc_seq_stop(struct seq_file *seq, void *v) 181 - __releases(dev_base_lock) 182 - { 183 - read_unlock(&dev_base_lock); 184 - } 185 - 186 - 187 159 static int dev_mc_seq_show(struct seq_file *seq, void *v) 188 160 { 189 161 struct dev_addr_list *m; 190 162 struct net_device *dev = v; 163 + 164 + if (v == SEQ_START_TOKEN) 165 + return 0; 191 166 192 167 netif_tx_lock_bh(dev); 193 168 for (m = dev->mc_list; m; m = m->next) { ··· 181 206 } 182 207 183 208 static const struct seq_operations dev_mc_seq_ops = { 184 - .start = dev_mc_seq_start, 185 - .next = dev_mc_seq_next, 186 - .stop = dev_mc_seq_stop, 209 + .start = dev_seq_start, 210 + .next = dev_seq_next, 211 + .stop = dev_seq_stop, 187 212 .show = dev_mc_seq_show, 188 213 }; 189 214