Skip to contentSkip to conversation

neighbour.c, pneigh_get_next() skips published entry

PATCH In review [email protected] 2 participants 2 messages Jun 2, 2006 – Jun 5, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 6/17 neighbour.c, pneigh_get_next() skips published entry

From: "Jari Takkala" <[email protected]>

Fix a problem where output from /proc/net/arp skips a record when the full output does not fit into the users read() buffer.

To reproduce: publish a large number of ARP entries (more than 10 required on my system). Run 'dd if=/proc/net/arp of=arp-1024.out bs=1024'. View the output, one entry will be missing.

---

 net/core/neighbour.c |    6 ++++++
 1 file changed, 6 insertions(+)
net/core/neighbour.c renamed from net/core/neighbour.c~neighbourc-pneigh_get_next-skips-published-entry +6 -0
diff -puN net/core/neighbour.c~neighbourc-pneigh_get_next-skips-published-entry net/core/neighbour.c
@@ -2138,6 +2138,12 @@ static struct pneigh_entry *pneigh_get_n
 	struct neigh_seq_state *state = seq->private;
 	struct neigh_table *tbl = state->tbl;
 
+	if (pos != NULL && *pos == 1 &&
+			(pn->next || tbl->phash_buckets[state->bucket])) {
+		--(*pos);
+		return pn;
+	}
+
 	pn = pn->next;
 	while (!pn) {
 		if (++state->bucket > PNEIGH_HASHMASK)

_

maintainer
#1 lore raw

From: [email protected]
Date: Thu, 01 Jun 2006 20:32:26 -0700

Quoted 11 lines

From: "Jari Takkala" <[email protected]>

Fix a problem where output from /proc/net/arp skips a record when the full output does not fit into the users read() buffer.

To reproduce: publish a large number of ARP entries (more than 10 required on my system). Run 'dd if=/proc/net/arp of=arp-1024.out bs=1024'. View the output, one entry will be missing.

This patch doesn't make any sense, I've been over it a few times.

The seqfile layer should take care of that user buffering issue transparently as long as we implement the interface callbacks properly.

Even if something needs to be fixed in the pneigh dumper, special casing *pos==1 doesn't look right. Also, if pneigh has this problem, how come the neigh seqfile iterators don't have the same problem or do they?