From: Yue Haibing <yuehaibing@huawei.com> hulk inclusion category: bugfix Link: https://gitee.com/openeuler/kernel/issues/ICBFCS CVE: NA -------------------------------- Make hash table size configurable to fix possible hash collision Signed-off-by: Yue Haibing <yuehaibing@huawei.com> --- net/oenetcls/oenetcls.h | 4 ++-- net/oenetcls/oenetcls_flow.c | 11 +++++++---- net/oenetcls/oenetcls_main.c | 8 ++++++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/net/oenetcls/oenetcls.h b/net/oenetcls/oenetcls.h index 255d368ac911..6d8e8e5e5b15 100644 --- a/net/oenetcls/oenetcls.h +++ b/net/oenetcls/oenetcls.h @@ -102,8 +102,6 @@ struct oecls_sock_flow_table { u32 ents[] ____cacheline_aligned_in_smp; }; -#define OECLS_DEV_FLOW_TABLE_NUM 0x1000 -#define OECLS_SOCK_FLOW_TABLE_NUM 0x100000 #define OECLS_DEV_FLOW_TABLE_SIZE(_num) (sizeof(struct oecls_dev_flow_table) + \ ((_num) * sizeof(struct oecls_dev_flow))) #define OECLS_SOCK_FLOW_TABLE_SIZE(_num) (offsetof(struct oecls_sock_flow_table, ents[_num])) @@ -135,6 +133,8 @@ extern int mode; extern int rcpu_probability; extern int oecls_netdev_num; extern int oecls_numa_num; +extern unsigned int dft_num; +extern unsigned int sft_num; #define oecls_debug(fmt, ...) \ do { \ diff --git a/net/oenetcls/oenetcls_flow.c b/net/oenetcls/oenetcls_flow.c index 07aca1308ec0..0953b4bd91ae 100644 --- a/net/oenetcls/oenetcls_flow.c +++ b/net/oenetcls/oenetcls_flow.c @@ -256,6 +256,11 @@ static void __oecls_set_cpu(struct sk_buff *skb, struct net_device *ndev, else newcpu = last_recv_cpu; + if (rflow->isvalid && cpu_to_node(rflow->cpu) == cpu_to_node(newcpu)) { + rflow->timeout = jiffies; + return; + } + if (cpu_to_node(cpu) == cpu_to_node(newcpu)) return; @@ -347,9 +352,8 @@ static int oecls_dev_flow_table_release(void) static int _oecls_dev_flow_table_init(struct net_device *netdev) { struct oecls_dev_flow_table *table; - int size = OECLS_DEV_FLOW_TABLE_NUM; + int size = dft_num, i, j, ret = 0; struct netdev_rx_queue *queue; - int i, j, ret = 0; size = roundup_pow_of_two(size); oecls_debug("dev:%s, num_rx_queues:%d, mask:0x%x\n", netdev->name, netdev->num_rx_queues, @@ -427,8 +431,7 @@ static int oecls_sock_flow_table_release(void) static int oecls_sock_flow_table_init(void) { struct oecls_sock_flow_table *table; - int size = OECLS_SOCK_FLOW_TABLE_NUM; - int i; + int size = sft_num, i; size = roundup_pow_of_two(size); table = vmalloc(OECLS_SOCK_FLOW_TABLE_SIZE(size)); diff --git a/net/oenetcls/oenetcls_main.c b/net/oenetcls/oenetcls_main.c index 4c542e3439d3..f9574b344331 100644 --- a/net/oenetcls/oenetcls_main.c +++ b/net/oenetcls/oenetcls_main.c @@ -51,6 +51,14 @@ static char irqname[64] = "comp"; module_param_string(irqname, irqname, sizeof(irqname), 0644); MODULE_PARM_DESC(irqname, "nic irq name string, default comp"); +unsigned int dft_num = 0x1000; +module_param(dft_num, uint, 0444); +MODULE_PARM_DESC(dft_num, "dev flow table entries, default 0x1000"); + +unsigned int sft_num = 0x100000; +module_param(sft_num, uint, 0444); +MODULE_PARM_DESC(sft_num, "sock flow table entries, default 0x100000"); + static bool check_params(void) { if (mode != 0 && mode != 1 && mode != 2) -- 2.34.1