flower match support for masked ports
Subsystems (2)
cover flower match support for masked ports
Hi,
This series is for adding support for flower match on masked src/dst ports.
Thanks,
Roi
Eli Britstein (3):
tc: flower: add u16 big endian parse option
tc_util: add functions for big endian masked numbers
tc: flower: support masked port destination and source match
man/man8/tc-flower.8 | 13 +++++----- tc/f_flower.c | 73 ++++++++++++++++++++++++++++++++++++++++------------ tc/tc_util.c | 12 +++++++++ tc/tc_util.h | 2 ++ 4 files changed, 77 insertions(+), 23 deletions(-)
Signature · 1 line
2.8.4
PATCH 1/3 tc: flower: add u16 big endian parse option
From: Eli Britstein <[email protected]>
Add u16 big endian parse option as a pre-step towards TCP/UDP/SCTP ports usage.
--- tc/f_flower.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tc/f_flower.c +7 -2
@@ -220,7 +220,7 @@ static int flower_parse_matching_flags(char *str, }static int flower_parse_u16 (char *str,int value_type,int mask_type, -struct nlmsghdr *n) +struct nlmsghdr *n,bool be) {__u16 value, mask;char *slash;
@@ -239,6 +239,10 @@ static int flower_parse_u16(char *str, int value_type, int mask_type, mask =UINT16_MAX ; } +if (be) { + value =htons (value); + mask =htons (mask); + }addattr16 (n,MAX_MSG , value_type, value);addattr16 (n,MAX_MSG , mask_type, mask);
@@ -284,7 +288,8 @@ static int flower_parse_ct_zone(char *str, struct nlmsghdr *n)return flower_parse_u16 (str,TCA_FLOWER_KEY_CT_ZONE ,TCA_FLOWER_KEY_CT_ZONE_MASK , - n); + n, + false); }static int flower_parse_ct_labels (char *str,struct nlmsghdr *n)
Signature · 1 line
2.8.4
PATCH 2/3 tc_util: add functions for big endian masked numbers
In reply to Roi DayanFrom: Eli Britstein <[email protected]>
Add functions for big endian masked numbers as a pre-step towards masked port numbers.
--- tc/tc_util.c | 12 ++++++++++++ tc/tc_util.h | 2 ++ 2 files changed, 14 insertions(+)
tc/tc_util.c +12 -0
@@ -985,3 +985,15 @@ void print_masked_u8(const char *name, struct rtattr *attr,print_masked_type (UINT8_MAX , __rta_getattr_u8_u32, name, attr, mask_attr, newline); } + +static __u32 __rta_getattr_be16_u32 (const struct rtattr *attr) +{ +return rta_getattr_be16 (attr); +} + +void print_masked_be16 (const char *name,struct rtattr *attr, +struct rtattr *mask_attr,bool newline) +{ +print_masked_type (UINT16_MAX , __rta_getattr_be16_u32, name, attr, + mask_attr, newline); +}
tc/tc_util.h +2 -0
@@ -133,4 +133,6 @@ void print_masked_u16(const char *name, struct rtattr *attr, struct rtattr *mask_attr, bool newline);void print_masked_u8 (const char *name,struct rtattr *attr,struct rtattr *mask_attr,bool newline); +void print_masked_be16 (const char *name,struct rtattr *attr, +struct rtattr *mask_attr,bool newline);#endif
Signature · 1 line
2.8.4
PATCH 3/3 tc: flower: support masked port destination and source match
In reply to Roi DayanFrom: Eli Britstein <[email protected]>
Extend destination and source port match to support masks, accepting both decimal and hexadecimal formats.
Also add missing documentation to synopsis in manpage.
$ tc qdisc add dev eth0 ingress
$ tc filter add dev eth0 protocol ip parent ffff: prio 1 flower skip_hw \
ip_proto tcp dst_port 1234/0xff00 action drop$ tc -s filter show dev eth0 parent ffff:
filter protocol ip pref 1 flower chain 0
filter protocol ip pref 1 flower chain 0 handle 0x1
eth_type ipv4
ip_proto tcp
dst_port 1234/0xff00
skip_hw
not_in_hw
action order 1: gact action drop
random type none pass val 0
index 1 ref 1 bind 1 installed 26 sec used 26 sec
Action statistics:
Sent 0 bytes 0 pkt (dropped 0, overlimits 0 requeues 0)
backlog 0b 0p requeues 0$ tc -p -j filter show dev eth0 parent ffff:
"options": {
"keys": {
"dst_port": 1234,
"dst_port_mask": 65280
...--- man/man8/tc-flower.8 | 13 ++++++----- tc/f_flower.c | 64 ++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 56 insertions(+), 21 deletions(-)
man/man8/tc-flower.8 +7 -6
@@ -57,7 +57,7 @@ flower \- flow based traffic control filter .BR dst_ip " | " src_ip " } " .IR PREFIX " | { " .BR dst_port " | " src_port " } { " -.IR port_number " | " +.IR MASKED_NUMBER " | " .IR min_port_number-max_port_number " } | " .B tcp_flags .IR MASKED_TCP_FLAGS " | "
@@ -221,12 +221,13 @@ must be a valid IPv4 or IPv6 address, depending on the \fBprotocol\fR option to tc filter, optionally followed by a slash and the prefix length. If the prefix is missing, \fBtc\fR assumes a full-length host match. .TP -.IR \fBdst_port " { " NUMBER " | " " MIN_VALUE-MAX_VALUE " } +.IR \fBdst_port " { " MASKED_NUMBER " | " " MIN_VALUE-MAX_VALUE " } .TQ -.IR \fBsrc_port " { " NUMBER " | " " MIN_VALUE-MAX_VALUE " } -Match on layer 4 protocol source or destination port number. Alternatively, the -mininum and maximum values can be specified to match on a range of layer 4 -protocol source or destination port numbers. Only available for +.IR \fBsrc_port " { " MASKED_NUMBER " | " " MIN_VALUE-MAX_VALUE " } +Match on layer 4 protocol source or destination port number, with an +optional mask. Alternatively, the mininum and maximum values can be +specified to match on a range of layer 4 protocol source or destination +port numbers. Only available for .BR ip_proto " values " udp ", " tcp " and " sctp which have to be specified in beforehand. .TP
tc/f_flower.c +49 -15
114 lines not on this page · raw message
Signature · 1 line
2.8.4
David Ahern
AppliedQuoted 13 lines · Roi Dayan
Hi,
This series is for adding support for flower match on masked src/dst ports.
Thanks,
RoiEli Britstein (3):
tc: flower: add u16 big endian parse option
tc_util: add functions for big endian masked numbers
tc: flower: support masked port destination and source match
Quoted 6 lines
man/man8/tc-flower.8 | 13 +++++----- tc/f_flower.c | 73 ++++++++++++++++++++++++++++++++++++++++------------ tc/tc_util.c | 12 +++++++++ tc/tc_util.h | 2 ++ 4 files changed, 77 insertions(+), 23 deletions(-)
applied to iproute2-next. Thanks