netfilter: xtables: Add snapshot of hardidletimer target
Subsystems (2)
PATCH 1/1 netfilter: xtables: Add snapshot of hardidletimer target
From: Manoj Basapathi <[email protected]>
This is a snapshot of hardidletimer netfilter target.
This patch implements a hardidletimer Xtables target that can be used to identify when interfaces have been idle for a certain period of time.
Timers are identified by labels and are created when a rule is set with a new label. The rules also take a timeout value (in seconds) as an option. If more than one rule uses the same timer label, the timer will be restarted whenever any of the rules get a hit.
One entry for each timer is created in sysfs. This attribute contains the timer remaining for the timer to expire. The attributes are located under the xt_idletimer class:
/sys/class/xt_hardidletimer/timers/<label>
When the timer expires, the target module sends a sysfs notification to the userspace, which can then decide what to do (eg. disconnect to save power)
Compared to IDLETIMER, HARDIDLETIMER can send notifications when CPU is in suspend too, to notify the timer expiry.
v1->v2: Moved all functionality into IDLETIMER module to avoid code duplication per comment from Florian.
--- include/uapi/linux/netfilter/xt_IDLETIMER.h | 3 + net/netfilter/xt_IDLETIMER.c | 85 ++++++++++++++++++++++++++--- 2 files changed, 79 insertions(+), 9 deletions(-)
include/uapi/linux/netfilter/xt_IDLETIMER.h +3 -0
@@ -33,12 +33,15 @@#include <linux/types.h> #define MAX_IDLETIMER_LABEL_SIZE 28 +#define XT_IDLETIMER_ALARM 0x01struct idletimer_tg_info {__u32 timeout;char label[MAX_IDLETIMER_LABEL_SIZE ]; +__u8 timer_type; +/* for kernel module internal use only */ struct idletimer_tg *timer __attribute__((aligned (8 ))); };
net/netfilter/xt_IDLETIMER.c +76 -9
164 lines not on this page · raw message
Signature · 1 line
1.9.1
Florian Westphal
maintainerQuoted 43 lines · Subash Abhinov Kasiviswanathan
From: Manoj Basapathi <[email protected]>
This is a snapshot of hardidletimer netfilter target.
This patch implements a hardidletimer Xtables target that can be used to identify when interfaces have been idle for a certain period of time.
Timers are identified by labels and are created when a rule is set with a new label. The rules also take a timeout value (in seconds) as an option. If more than one rule uses the same timer label, the timer will be restarted whenever any of the rules get a hit.
One entry for each timer is created in sysfs. This attribute contains the timer remaining for the timer to expire. The attributes are located under the
xt_idletimerclass:/sys/class/xt_hardidletimer/timers/<label>
When the timer expires, the target module sends a sysfs notification to the userspace, which can then decide what to do (eg. disconnect to save power)
Compared to IDLETIMER, HARDIDLETIMER can send notifications when CPU is in suspend too, to notify the timer expiry.
v1->v2: Moved all functionality into IDLETIMER module to avoid code duplication per comment from Florian.Signed-off-by Manoj Basapathi <[email protected]>Signed-off-by Subash Abhinov Kasiviswanathan <[email protected]>--- include/uapi/linux/netfilter/xt_IDLETIMER.h | 3 + net/netfilter/xt_IDLETIMER.c | 85 ++++++++++++++++++++++++++--- 2 files changed, 79 insertions(+), 9 deletions(-)include/uapi/linux/netfilter/xt_IDLETIMER.h +0
-0@@ -33,12 +33,15 @@#include <linux/types.h>
include/uapi/linux/netfilter/xt_IDLETIMER.h line 44
Quoted 10 lines
include/uapi/linux/netfilter/xt_IDLETIMER.h +3
-0#define MAX_IDLETIMER_LABEL_SIZE 28 +#define XT_IDLETIMER_ALARM 0x01struct idletimer_tg_info {__u32 timeout;char label[MAX_IDLETIMER_LABEL_SIZE ]; +__u8 timer_type; +
This breaks binary abi of idletimer_tg_info.
You will need to add a new target revision for this, i.e. struct idletimer_tg_info_v1.
See net/netfilter/xt_CT.c for an example target that has several revisions.