From 2f3702e5ad192b193c3e40a3fcc28eb418f7e76f Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 13 Sep 2012 14:01:40 +0200 Subject: [PATCH] pf plugin: Remove the init() callback. Instead check for a running PF in the read() callback. --- src/pf.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/src/pf.c b/src/pf.c index 05b3cb58..4b5154d5 100644 --- a/src/pf.c +++ b/src/pf.c @@ -63,6 +63,9 @@ static int pf_read (void) close(pfdev); + if (!status.running) + return (-1); + for (i = 0; i < PFRES_MAX; i++) submit_counter("pf_counters", cnames[i], status.counters[i], 0); for (i = 0; i < LCNT_MAX; i++) @@ -77,31 +80,7 @@ static int pf_read (void) return (0); } -static int pf_init (void) -{ - struct pf_status status; - int pfdev = -1; - - if ((pfdev = open(pf_device, O_RDONLY)) == -1) { - ERROR("unable to open %s", pf_device); - return (-1); - } - - if (ioctl(pfdev, DIOCGETSTATUS, &status) == -1) { - ERROR("DIOCGETSTATUS: %i", pfdev); - close(pfdev); - return (-1); - } - - close(pfdev); - if (!status.running) - return (-1); - - return (0); -} - void module_register (void) { - plugin_register_init("pf", pf_init); plugin_register_read("pf", pf_read); } -- 2.30.2