History

net: sched: cls_flower: Classify packets using port ranges

Added support in tc flower for filtering based on port ranges. Example: 1. Match on a port range: ------------------------- $ tc filter add dev enp4s0 protocol ip parent ffff:\ prio 1 flower ip_proto tcp dst_port range 20-30 skip_hw\ action drop $ tc -s filter show dev enp4s0 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 range 20-30 skip_hw not_in_hw action order 1: gact action drop random type none pass val 0 index 1 ref 1 bind 1 installed 85 sec used 3 sec Action statistics: Sent 460 bytes 10 pkt (dropped 10, overlimits 0 requeues 0) backlog 0b 0p requeues 0 2. Match on IP address and port range: -------------------------------------- $ tc filter add dev enp4s0 protocol ip parent ffff:\ prio 1 flower dst_ip 192.168.1.1 ip_proto tcp dst_port range 100-200\ skip_hw action drop $ tc -s filter show dev enp4s0 parent ffff: filter protocol ip pref 1 flower chain 0 handle 0x2 eth_type ipv4 ip_proto tcp dst_ip 192.168.1.1 dst_port range 100-200 skip_hw not_in_hw action order 1: gact action drop random type none pass val 0 index 2 ref 1 bind 1 installed 58 sec used 2 sec Action statistics: Sent 920 bytes 20 pkt (dropped 20, overlimits 0 requeues 0) backlog 0b 0p requeues 0 v4: 1. Added condition before setting port key. 2. Organized setting and dumping port range keys into functions and added validation of input range. v3: 1. Moved new fields in UAPI enum to the end of enum. 2. Removed couple of empty lines. v2: Addressed Jiri's comments: 1. Added separate functions for dst and src comparisons. 2. Removed endpoint enum. 3. Added new bit TCA_FLOWER_FLAGS_RANGE to decide normal/range lookup. 4. Cleaned up fl_lookup function. Signed-off-by: Amritha Nambiar <amritha.nambiar@intel.com>

Amritha Nambiar committed 8 years ago

Commit 5c722991 parent 7fe50ac2 files · +156 −6Browse files

Showing the changes to include/uapi/linux (1 of 2 files). Show all

Unified · Split

include/uapi/linux/pkt_cls.h+7−0
@@ -485,6 +485,11 @@ enum { · 484 unmodified lines
485485
486486 TCA_FLOWER_IN_HW_COUNT,
487487
488+ TCA_FLOWER_KEY_PORT_SRC_MIN, /* be16 */
489+ TCA_FLOWER_KEY_PORT_SRC_MAX, /* be16 */
490+ TCA_FLOWER_KEY_PORT_DST_MIN, /* be16 */
491+ TCA_FLOWER_KEY_PORT_DST_MAX, /* be16 */
492+
488493 __TCA_FLOWER_MAX,
489494 };
490495
@@ -518,6 +523,8 @@ enum { · 27 unmodified lines
518523 TCA_FLOWER_KEY_FLAGS_FRAG_IS_FIRST = (1 << 1),
519524 };
520525
526+#define TCA_FLOWER_MASK_FLAGS_RANGE (1 << 0) /* Range-based match */
527+
521528 /* Match-all classifier */
522529
523530 enum {