diff options
| author | Luciano Coelho <luciano.coelho@nokia.com> | 2010-06-15 09:04:00 -0400 |
|---|---|---|
| committer | Patrick McHardy <kaber@trash.net> | 2010-06-15 09:04:00 -0400 |
| commit | 0902b469bd25065aa0688c3cee6f11744c817e7c (patch) | |
| tree | b7e1516da57ee49d98de0789a19fc283b50bf1de /include/linux | |
| parent | d73f33b168831e53972fbf7c85db87950a41436c (diff) | |
netfilter: xtables: idletimer target implementation
This patch implements an idletimer 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_idletimer/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).
Cc: Timo Teras <timo.teras@iki.fi>
Signed-off-by: Luciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: Patrick McHardy <kaber@trash.net>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/netfilter/Kbuild | 1 | ||||
| -rw-r--r-- | include/linux/netfilter/xt_IDLETIMER.h | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/include/linux/netfilter/Kbuild b/include/linux/netfilter/Kbuild index 48767cd16453..bb103f43afa0 100644 --- a/include/linux/netfilter/Kbuild +++ b/include/linux/netfilter/Kbuild | |||
| @@ -8,6 +8,7 @@ header-y += xt_CONNMARK.h | |||
| 8 | header-y += xt_CONNSECMARK.h | 8 | header-y += xt_CONNSECMARK.h |
| 9 | header-y += xt_CT.h | 9 | header-y += xt_CT.h |
| 10 | header-y += xt_DSCP.h | 10 | header-y += xt_DSCP.h |
| 11 | header-y += xt_IDLETIMER.h | ||
| 11 | header-y += xt_LED.h | 12 | header-y += xt_LED.h |
| 12 | header-y += xt_MARK.h | 13 | header-y += xt_MARK.h |
| 13 | header-y += xt_NFLOG.h | 14 | header-y += xt_NFLOG.h |
diff --git a/include/linux/netfilter/xt_IDLETIMER.h b/include/linux/netfilter/xt_IDLETIMER.h new file mode 100644 index 000000000000..3e1aa1be942e --- /dev/null +++ b/include/linux/netfilter/xt_IDLETIMER.h | |||
| @@ -0,0 +1,45 @@ | |||
| 1 | /* | ||
| 2 | * linux/include/linux/netfilter/xt_IDLETIMER.h | ||
| 3 | * | ||
| 4 | * Header file for Xtables timer target module. | ||
| 5 | * | ||
| 6 | * Copyright (C) 2004, 2010 Nokia Corporation | ||
| 7 | * Written by Timo Teras <ext-timo.teras@nokia.com> | ||
| 8 | * | ||
| 9 | * Converted to x_tables and forward-ported to 2.6.34 | ||
| 10 | * by Luciano Coelho <luciano.coelho@nokia.com> | ||
| 11 | * | ||
| 12 | * Contact: Luciano Coelho <luciano.coelho@nokia.com> | ||
| 13 | * | ||
| 14 | * This program is free software; you can redistribute it and/or | ||
| 15 | * modify it under the terms of the GNU General Public License | ||
| 16 | * version 2 as published by the Free Software Foundation. | ||
| 17 | * | ||
| 18 | * This program is distributed in the hope that it will be useful, but | ||
| 19 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 21 | * General Public License for more details. | ||
| 22 | * | ||
| 23 | * You should have received a copy of the GNU General Public License | ||
| 24 | * along with this program; if not, write to the Free Software | ||
| 25 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
| 26 | * 02110-1301 USA | ||
| 27 | */ | ||
| 28 | |||
| 29 | #ifndef _XT_IDLETIMER_H | ||
| 30 | #define _XT_IDLETIMER_H | ||
| 31 | |||
| 32 | #include <linux/types.h> | ||
| 33 | |||
| 34 | #define MAX_IDLETIMER_LABEL_SIZE 28 | ||
| 35 | |||
| 36 | struct idletimer_tg_info { | ||
| 37 | __u32 timeout; | ||
| 38 | |||
| 39 | char label[MAX_IDLETIMER_LABEL_SIZE]; | ||
| 40 | |||
| 41 | /* for kernel module internal use only */ | ||
| 42 | struct idletimer_tg *timer __attribute((aligned(8))); | ||
| 43 | }; | ||
| 44 | |||
| 45 | #endif | ||
