From cbbab701276a0400a30275fdbd28bafb4d25b468 Mon Sep 17 00:00:00 2001 From: Vishal Deep Ajmera Date: Wed, 10 Jul 2019 19:02:30 +0530 Subject: [PATCH] flow: Wildcard UDP ports when using SYMMETRIC_L4 hash for select groups. UDP source and destination ports are not used to derive the hash index used for selecting the bucket in case of SYMMETRIC_L4 hash based select groups. However, they are un-wildcarded in the megaflow entry match criteria. This results in distinct megaflow entry being created for each pair of UDP source and destination ports unnecessarily and causes significant performance deterioration when the megaflow cache limit is reached. This patch wildcards UDP ports when using select group with SYMMETRIC_L4 hash function. Signed-off-by: Vishal Deep Ajmera CC: Jan Scheurich Signed-off-by: Ben Pfaff --- lib/flow.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/flow.c b/lib/flow.c index de9370449..95da7d4b1 100644 --- a/lib/flow.c +++ b/lib/flow.c @@ -2478,7 +2478,12 @@ flow_mask_hash_fields(const struct flow *flow, struct flow_wildcards *wc, } if (is_ip_any(flow)) { memset(&wc->masks.nw_proto, 0xff, sizeof wc->masks.nw_proto); - flow_unwildcard_tp_ports(flow, wc); + /* Unwildcard port only for non-UDP packets as udp port + * numbers are not used in hash calculations. + */ + if (flow->nw_proto != IPPROTO_UDP) { + flow_unwildcard_tp_ports(flow, wc); + } } for (i = 0; i < FLOW_MAX_VLAN_HEADERS; i++) { wc->masks.vlans[i].tci |= htons(VLAN_VID_MASK | VLAN_CFI); -- 2.39.5