[NETFILTER]: x_tables: add rateest match
Add rate estimator match. The rate estimator match can match on estimated rates by the RATEEST target. It supports matching on absolute bps/pps values, comparing two rate estimators and matching on the difference between two rate estimators. This is what I use to route outgoing data connections from a FTP server over two lines based on the available bandwidth: # estimate outgoing rates iptables -t mangle -A POSTROUTING -o eth0 -j RATEEST --rateest-name eth0 \ --rateest-interval 250ms \ --rateest-ewma 0.5s iptables -t mangle -A POSTROUTING -o ppp0 -j RATEEST --rateest-name ppp0 \ --rateest-interval 250ms \ --rateest-ewma 0.5s # mark based on available bandwidth iptables -t mangle -A BALANCE -m state --state NEW \ -m helper --helper ftp \ -m rateest --rateest-delta \ --rateest1 eth0 \ --rateest-bps1 2.5mbit \ --rateest-gt \ --rateest2 ppp0 \ --rateest-bps2 2mbit \ -j CONNMARK --set-mark 0x1 iptables -t mangle -A BALANCE -m state --state NEW \ -m helper --helper ftp \ -m rateest --rateest-delta \ --rateest1 ppp0 \ --rateest-bps1 2mbit \ --rateest-gt \ --rateest2 eth0 \ --rateest-bps2 2.5mbit \ -j CONNMARK --set-mark 0x2 iptables -t mangle -A BALANCE -j CONNMARK --restore-mark Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
5859034d7e
commit
50c164a81f
@@ -30,6 +30,7 @@ header-y += xt_multiport.h
|
||||
header-y += xt_owner.h
|
||||
header-y += xt_pkttype.h
|
||||
header-y += xt_policy.h
|
||||
header-y += xt_rateest.h
|
||||
header-y += xt_realm.h
|
||||
header-y += xt_sctp.h
|
||||
header-y += xt_state.h
|
||||
|
33
include/linux/netfilter/xt_rateest.h
Normal file
33
include/linux/netfilter/xt_rateest.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef _XT_RATEEST_MATCH_H
|
||||
#define _XT_RATEEST_MATCH_H
|
||||
|
||||
enum xt_rateest_match_flags {
|
||||
XT_RATEEST_MATCH_INVERT = 1<<0,
|
||||
XT_RATEEST_MATCH_ABS = 1<<1,
|
||||
XT_RATEEST_MATCH_REL = 1<<2,
|
||||
XT_RATEEST_MATCH_DELTA = 1<<3,
|
||||
XT_RATEEST_MATCH_BPS = 1<<4,
|
||||
XT_RATEEST_MATCH_PPS = 1<<5,
|
||||
};
|
||||
|
||||
enum xt_rateest_match_mode {
|
||||
XT_RATEEST_MATCH_NONE,
|
||||
XT_RATEEST_MATCH_EQ,
|
||||
XT_RATEEST_MATCH_LT,
|
||||
XT_RATEEST_MATCH_GT,
|
||||
};
|
||||
|
||||
struct xt_rateest_match_info {
|
||||
char name1[IFNAMSIZ];
|
||||
char name2[IFNAMSIZ];
|
||||
u_int16_t flags;
|
||||
u_int16_t mode;
|
||||
u_int32_t bps1;
|
||||
u_int32_t pps1;
|
||||
u_int32_t bps2;
|
||||
u_int32_t pps2;
|
||||
struct xt_rateest *est1 __attribute__((aligned(8)));
|
||||
struct xt_rateest *est2 __attribute__((aligned(8)));
|
||||
};
|
||||
|
||||
#endif /* _XT_RATEEST_MATCH_H */
|
Reference in New Issue
Block a user