On Fri, 2007-02-09 at 10:02 -0500, Gentoo-Wally wrote:
> The capture information in /proc/net/pf_ring/ for a particular capture
> application is very useful, but when using multiple capture
> applications it is sometimes difficult to identify what statistics
> belong to which application. I was wondering if it would be possible
> to instead of using 0, 1, 2...etc to use the PID instead?
Attached patch implements this functionality.
Forget about the first patch, it missed the remove_proc function.
This works ok for me but you are out of luck if Luca doesn't like this
patch.
Notice: the modified module_param() calls should make it into mainstream
cause they fix the ring_packet.c compile issues with kernel 2.6.20.
The last parameter of module_param should not be a default value but a
permission. See Changelog-2.6.20
Cheers,
Michael
--- net/ring/ring_packet.c.orig 2007-02-12 12:43:38.000000000 +0100
+++ net/ring/ring_packet.c 2007-02-12 13:44:09.000000000 +0100
@@ -98,7 +98,7 @@
struct ring_opt {
struct net_device *ring_netdev;
- u_short ring_id;
+ pid_t ring_pid;
/* Cluster */
u_short cluster_id; /* 0 = no cluster */
@@ -152,7 +152,6 @@
static void ring_proc_remove(struct ring_opt *pfr);
static void ring_proc_init(void);
static void ring_proc_term(void);
-static int ring_count = 0;
/* ********************************** */
@@ -177,11 +176,11 @@
transparent_mode = 1, enable_tx_capture = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16))
-module_param(bucket_len, int, 128);
-module_param(num_slots, int, 4096);
-module_param(sample_rate, int, 1);
-module_param(transparent_mode, int, 1);
-module_param(enable_tx_capture, int, 0);
+module_param(bucket_len, int, 0644);
+module_param(num_slots, int, 0644);
+module_param(sample_rate, int, 0644);
+module_param(transparent_mode, int, 0644);
+module_param(enable_tx_capture, int, 0644);
#else
MODULE_PARM(bucket_len, "i");
MODULE_PARM(num_slots, "i");
@@ -263,9 +262,9 @@
if(ring_proc_dir != NULL) {
char name[16];
- pfr->ring_id = ring_count++;
+ pfr->ring_pid = current->pid;
- snprintf(name, sizeof(name), "%d", pfr->ring_id);
+ snprintf(name, sizeof(name), "%d", pfr->ring_pid);
create_proc_read_entry(name, 0, ring_proc_dir,
ring_proc_get_info, pfr);
/* printk("PF_RING: added /proc/net/pf_ring/%s\n", name); */
@@ -278,7 +277,8 @@
if(ring_proc_dir != NULL) {
char name[16];
- snprintf(name, sizeof(name), "%d", pfr->ring_id);
+ snprintf(name, sizeof(name), "%d", pfr->ring_pid);
+
remove_proc_entry(name, ring_proc_dir);
/* printk("PF_RING: removed /proc/net/pf_ring/%s\n", name); */
}
_______________________________________________
Ntop-misc mailing list
[email protected]
http://listgateway.unipi.it/mailman/listinfo/ntop-misc