: add xt_RATEEST target
RFC 3/4 : add xt_RATEEST target
[IPTABLES]: add xt_RATEEST target
linux/netfilter/xt_RATEEST.h +11 -0
@@ -0,0 +1,11 @@ +#ifndef _XT_RATEEST_TARGET_H +#define _XT_RATEEST_TARGET_H + +struct xt_rateest_target_info { +char name[IFNAMSIZ ]; +signed char interval; +unsigned char ewma_log; +struct xt_rateest *est __attribute__((aligned (8 ))); +}; + +#endif /* _XT_RATEEST_TARGET_H */
libxt_RATEEST.c +240 -0
240 lines not on this page · raw message
Makefile +1 -1
@@ -7,7 +7,7 @@ # PF_EXT_SLIB:=ah addrtype conntrack ecn icmp iprange owner policy realm recent tos ttl unclean CLUSTERIP DNAT ECN LOG MASQUERADE MIRROR NETMAP REDIRECT REJECT SAME SNAT TOS TTL ULOG PF6_EXT_SLIB:=ah dst eui64 frag hbh hl icmp6 ipv6header mh owner policy rt HL LOG REJECT -PFX_EXT_SLIB:=connbytes connmark connlimit comment dccp dscp esp hashlimit helper length limit mac mark multiport physdev pkttype quota sctp state statistic standard string tcp tcpmss time u32 udp CLASSIFY CONNMARK DSCP MARK NFLOG NFQUEUE NOTRACK TCPMSS TRACE +PFX_EXT_SLIB:=connbytes connmark connlimit comment dccp dscp esp hashlimit helper length limit mac mark multiport physdev pkttype quota sctp state statistic standard string tcp tcpmss time u32 udp CLASSIFY CONNMARK DSCP MARK NFLOG NFQUEUE NOTRACK RATEEST TCPMSS TRACE PF_EXT_SELINUX_SLIB:= PF6_EXT_SELINUX_SLIB:=
Makefile +2 -2
@@ -80,7 +80,7 @@ STATIC_LIBS = STATIC6_LIBS = LDFLAGS = -rdynamic -LDLIBS = -ldl +LDLIBS = -ldl -lm ifeq ($(DO_SELINUX), 1) LDLIBS += -lselinux endif
@@ -89,7 +89,7 @@ STATIC_LIBS = extensions/libext.a STATIC6_LIBS = extensions/libext6.a LDFLAGS = -static -LDLIBS = +LDLIBS = -lm ifeq ($(DO_SELINUX), 1) LDLIBS += -lselinux endif
Quoted 16 lines · Patrick McHardy
Date: Sun, 25 Nov 2007 18:11:55 +0100
From: Patrick McHardy <[email protected]>
To: Netfilter Development Mailinglist <[email protected]>
Subject: [RFC IPTABLES 3/4]: addxt_RATEESTtarget[IPTABLES]: add
xt_RATEESTtargetSigned-off-by Patrick McHardy <[email protected]>Index:
include/linux/netfilter/xt_RATEEST.h
===================================================================
linux/netfilter/xt_RATEEST.h line 7
Quoted 7 lines
linux/netfilter/xt_RATEEST.h +7
-0@@ -0,0 +1,11 @@ +#ifndef _XT_RATEEST_TARGET_H +#define _XT_RATEEST_TARGET_H + +struct xt_rateest_target_info { + char name[IFNAMSIZ]; + signed char interval; + unsigned char ewma_log;
int8/uint8
Quoted 18 lines
linux/netfilter/xt_RATEEST.h +4
-0+ struct xt_rateest *est __attribute__((aligned(8))); +}; + +#endif /* _XT_RATEEST_TARGET_H */ Index:
extensions/libxt_RATEEST.c
===================================================================libxt_RATEEST.c +8
-0@@ -0,0 +1,240 @@ +static unsigned int interval; +static unsigned int ewma_log; +static void +RATEEST_final_check (unsigned int flags) +{ +struct xt_rateest_target_info *info = RATEEST_info; + +if (!(flags & (1 <<RATEEST_OPT_NAME )))
libxt_RATEEST.c line 157
Quoted 10 lines
libxt_RATEEST.c +10
-0+exit_error (PARAMETER_PROBLEM ,"RATEEST: no name specified" ); +if (!(flags & (1 <<RATEEST_OPT_INTERVAL ))) +exit_error (PARAMETER_PROBLEM ,"RATEEST: no interval specified" ); +if (!(flags & (1 <<RATEEST_OPT_EWMALOG ))) +exit_error (PARAMETER_PROBLEM ,"RATEEST: no ewmalog specified" ); + +for (info->interval =0 ; info->interval <=5 ; info->interval++) { +if (interval <= (1 << info->interval) * (TIME_UNITS_PER_SEC /4 )) +break ; + }
-{}
libxt_RATEEST.c line 181
Quoted 6 lines
libxt_RATEEST.c +6
-0+static void +__RATEEST_print (const struct xt_entry_target *target,const char *prefix) +{ +struct xt_rateest_target_info *info = (void *)target->data; +unsigned int interval; +unsigned int ewma_log;
Ouchie - that throws a warning with -Wshadow (which is what I'm trying to slip in later).
libxt_RATEEST.c line 184
Quoted 3 lines
libxt_RATEEST.c +3
-0+ + interval = (TIME_UNITS_PER_SEC << (info->interval +2 )) /4 ; + ewma_log = interval * (1 << (info->ewma_log));
ewma_log = interval << info->ewma_log;
libxt_RATEEST.c
Quoted 11 lines
libxt_RATEEST.c +8
-1+printf ("%sname %s " , prefix, info->name); +printf ("%sinterval " , prefix); +RATEEST_print_time (interval); +printf ("%sewmalog " , prefix); +RATEEST_print_time (ewma_log); +} + -LDLIBS = -ldl +LDLIBS = -ldl -lm
I have not seen the function that requires -lm, which was it?
Quoted 12 lines · Jan Engelhardt
libxt_RATEEST.c line 157
Quoted 8 lines · Patrick McHardy
libxt_RATEEST.c +8
-0+static void +RATEEST_final_check (unsigned int flags) +{ + ... +for (info->interval =0 ; info->interval <=5 ; info->interval++) { +if (interval <= (1 << info->interval) * (TIME_UNITS_PER_SEC /4 )) +break ; + }-{}
For multiple statements they're fine.
Quoted 9 lines
libxt_RATEEST.c line 181
Quoted 6 lines
libxt_RATEEST.c +6
-0+static void +__RATEEST_print (const struct xt_entry_target *target,const char *prefix) +{ +struct xt_rateest_target_info *info = (void *)target->data; +unsigned int interval; +unsigned int ewma_log;Ouchie - that throws a warning with -Wshadow (which is what I'm trying to slip in later).
Will rename.
Quoted 5 lines
libxt_RATEEST.c line 184
Quoted 3 lines
libxt_RATEEST.c +3
-0+ + interval = (TIME_UNITS_PER_SEC << (info->interval +2 )) /4 ; + ewma_log = interval * (1 << (info->ewma_log));
ewma_log= interval <<info->ewma_log;
OK.
Quoted 10 lines
Quoted 8 lines
libxt_RATEEST.c +7
-0+printf ("%sname %s " , prefix, info->name); +printf ("%sinterval " , prefix); +RATEEST_print_time (interval); +printf ("%sewmalog " , prefix); +RATEEST_print_time (ewma_log); +} +
Quoted 4 lines
Makefile line 83
Quoted 2 lines
Makefile +1
-1-LDLIBS = -ldl +LDLIBS = -ldl -lmI have not seen the function that requires -lm, which was it?
log():
+ if (interval / (-log(w)) > ewma_log)