Skip to content

Commit 95a3635

Browse files
xemuldavem330
authored andcommitted
[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>
1 parent fd80eb9 commit 95a3635

1 file changed

Lines changed: 6 additions & 31 deletions

File tree

‎net/core/dev_mcast.c‎

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -156,39 +156,14 @@ void dev_mc_unsync(struct net_device *to, struct net_device *from)
156156
EXPORT_SYMBOL(dev_mc_unsync);
157157

158158
#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-
187159
static int dev_mc_seq_show(struct seq_file *seq, void *v)
188160
{
189161
struct dev_addr_list *m;
190162
struct net_device *dev = v;
191163

164+
if (v == SEQ_START_TOKEN)
165+
return 0;
166+
192167
netif_tx_lock_bh(dev);
193168
for (m = dev->mc_list; m; m = m->next) {
194169
int i;
@@ -206,9 +181,9 @@ static int dev_mc_seq_show(struct seq_file *seq, void *v)
206181
}
207182

208183
static const struct seq_operations dev_mc_seq_ops = {
209-
.start = dev_mc_seq_start,
210-
.next = dev_mc_seq_next,
211-
.stop = dev_mc_seq_stop,
184+
.start = dev_seq_start,
185+
.next = dev_seq_next,
186+
.stop = dev_seq_stop,
212187
.show = dev_mc_seq_show,
213188
};
214189

0 commit comments

Comments
 (0)