Skip to contentSkip to conversation

Consolidate proc interface (v2)

PATCH In review Pavel Emelyanov 2 participants 2 messages Nov 16, 2007 – Nov 20, 2007

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

PATCH 6/6 Consolidate proc interface (v2)

Both ipv6/raw.c and ipv4/raw.c use the seq files to walk through the raw sockets hash and show them.

The "walking" code is rather huge, but is identical in both cases. The difference is the hash table to walk over and the protocol family to check (this was not in the first virsion of the patch, which was noticed by YOSHIFUJI)

Make the ->open store the needed hash table and the family on the allocated raw_iter_state and make the start/next/stop callbacks work with it.

This removes most of the code.

---

include/net/raw.h +14 -0
index 81a1773..4d1aba0 100644
@@ -37,6 +37,20 @@ struct raw_hashinfo {
 #ifdef CONFIG_PROC_FS
 extern int  raw_proc_init(void);
 extern void raw_proc_exit(void);
+
+struct raw_iter_state {
+	int bucket;
+	unsigned short family;
+	struct raw_hashinfo *h;
+};
+
+#define raw_seq_private(seq) ((struct raw_iter_state *)(seq)->private)
+void *raw_seq_start(struct seq_file *seq, loff_t *pos);
+void *raw_seq_next(struct seq_file *seq, void *v, loff_t *pos);
+void raw_seq_stop(struct seq_file *seq, void *v);
+int raw_seq_open(struct file *file, struct raw_hashinfo *h,
+		unsigned short family);
+
 #endif
 
 void raw_hash_sk(struct sock *sk, struct raw_hashinfo *h);
net/ipv4/raw.c +34 -18

103 lines not on this page · raw message

net/ipv6/raw.c +5 -77

103 lines not on this page · raw message

maintainer
#1 lore raw

From: Pavel Emelyanov <[email protected]>
Date: Fri, 16 Nov 2007 18:06:16 +0300

Quoted 8 lines

Both ipv6/raw.c and ipv4/raw.c use the seq files to walk through the raw sockets hash and show them.

The "walking" code is rather huge, but is identical in both cases. The difference is the hash table to walk over and the protocol family to check (this was not in the first virsion of the patch, which was noticed by YOSHIFUJI)

Quoted 7 lines

Make the ->open store the needed hash table and the family on the allocated raw_iter_state and make the start/next/stop callbacks work with it.

This removes most of the code.

Also applied, thanks a lot.