[PATCH v2 22/23] netoops: Add one-shot mode

From: Mike Waychison
Date: Mon Nov 08 2010 - 15:34:23 EST


Sometimes it is possible to have a kernel crashing that continuously
Oopses. In this case, we do not want the network dumper get called over
and over again, as we may only be interested in the first Oops that a
kernel emits (especially in cases where we panic_on_oops).

In order to support this dumping policy, this commit introduces a file
call /proc/sys/kernel/net_dump_one_shot that contains a boolean as to
whether or not the netoops driver will operate in one-shot mode.

Note that 'soft' dumps do not disable the netoops driver when one-shot
mode is enabled.

Signed-off-by: Mike Waychison <mikew@xxxxxxxxxx>
---
TODO: ABI needs a better home.
---
drivers/net/netoops.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)

diff --git a/drivers/net/netoops.c b/drivers/net/netoops.c
index 5cbb732..1ffd0f0 100644
--- a/drivers/net/netoops.c
+++ b/drivers/net/netoops.c
@@ -97,6 +97,8 @@ struct netoops_msg {
} __attribute__ ((packed));

static struct netoops_msg msg;
+static int network_dumper_one_shot = 1;
+static int network_dumper_disabled;

static char netoops_fw_version[80];
static char netoops_board_name[80];
@@ -221,6 +223,10 @@ static void netoops(struct kmsg_dumper *dumper, enum kmsg_dump_reason reason,
netoops_send_segment(packet_count_2, s1, l1);
}

+ /* Should we disable ourselves now? */
+ if (!soft_dump && network_dumper_one_shot)
+ network_dumper_disabled = 1;
+
spin_unlock_irqrestore(&targets.lock, flags);
}

@@ -282,6 +288,28 @@ static struct kmsg_dumper netoops_dumper = {
.dump = netoops,
};

+static struct ctl_table kern_table[] = {
+ {
+ .procname = "net_dump_one_shot",
+ .data = &network_dumper_one_shot,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_dointvec,
+ },
+ {},
+};
+
+static struct ctl_table root_table[] = {
+ {
+ .procname = "kernel",
+ .mode = 0555,
+ .child = kern_table,
+ },
+ {}
+};
+
+static struct ctl_table_header *proc_table_header;
+
static int __init netoops_init(void)
{
int retval = -EINVAL;
@@ -309,7 +337,15 @@ static int __init netoops_init(void)
if (retval)
goto out_sysfs_group;

+ proc_table_header = register_sysctl_table(root_table);
+ if (!proc_table_header) {
+ retval = -EINVAL;
+ goto out_kmsg_dump;
+ }
+
return 0;
+out_kmsg_dump:
+ kmsg_dump_unregister(&netoops_dumper);
out_sysfs_group:
sysfs_remove_group(netoops_kobj, &attr_group);
out_kobj:
@@ -322,6 +358,7 @@ out:

static void __exit netoops_exit(void)
{
+ unregister_sysctl_table(proc_table_header);
kmsg_dump_unregister(&netoops_dumper);
sysfs_remove_group(netoops_kobj, &attr_group);
kobject_put(netoops_kobj);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/