1 Star 0 Fork 32

fantaotao1/gazelle

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0227-fix-config-flow-rule-race.patch 5.17 KB
一键复制 编辑 原始数据 按行查看 历史
jinag12 提交于 2023-05-13 16:12 . sync fix build err with dpdk-21.11
From b393509c3e7352ddc2457bca766a7dcff579b3f0 Mon Sep 17 00:00:00 2001
From: jiangheng12 <jiangheng14@huawei.com>
Date: Thu, 30 Mar 2023 16:20:34 +0800
Subject: [PATCH] fix config flow rule race
---
src/common/gazelle_dfx_msg.h | 2 +-
src/lstack/netif/lstack_ethdev.c | 6 +++---
src/lstack/netif/lstack_vdev.c | 21 ++++++++++-----------
3 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/src/common/gazelle_dfx_msg.h b/src/common/gazelle_dfx_msg.h
index 9105871..e4da687 100644
--- a/src/common/gazelle_dfx_msg.h
+++ b/src/common/gazelle_dfx_msg.h
@@ -200,7 +200,7 @@ struct gazelle_stat_low_power_info {
};
#define RTE_ETH_XSTATS_NAME_SIZE 64
-#define RTE_ETH_XSTATS_MAX_LEN 128
+#define RTE_ETH_XSTATS_MAX_LEN 256
struct nic_eth_xstats_name {
char name[RTE_ETH_XSTATS_NAME_SIZE];
};
diff --git a/src/lstack/netif/lstack_ethdev.c b/src/lstack/netif/lstack_ethdev.c
index 8d05bdd..52aa9a8 100644
--- a/src/lstack/netif/lstack_ethdev.c
+++ b/src/lstack/netif/lstack_ethdev.c
@@ -152,7 +152,7 @@ int32_t eth_dev_poll(void)
}
/* flow rule map */
-#define RULE_KEY_LEN 22
+#define RULE_KEY_LEN 23
struct flow_rule {
char rule_key[RULE_KEY_LEN];
struct rte_flow *flow;
@@ -322,7 +322,7 @@ create_flow_director(uint16_t port_id, uint16_t queue_id, uint32_t src_ip, uint3
void config_flow_director(uint16_t queue_id, uint32_t src_ip, uint32_t dst_ip, uint16_t src_port, uint16_t dst_port){
uint16_t port_id = get_port_id();
- char rule_key[RULE_KEY_LEN];
+ char rule_key[RULE_KEY_LEN] = {0};
sprintf(rule_key,"%u_%u_%u",src_ip,src_port,dst_port);
struct flow_rule *fl_exist = find_rule(rule_key);
if(fl_exist != NULL){
@@ -346,7 +346,7 @@ void config_flow_director(uint16_t queue_id, uint32_t src_ip, uint32_t dst_ip, u
void delete_flow_director(uint32_t dst_ip, uint16_t src_port, uint16_t dst_port)
{
uint16_t port_id = get_port_id();
- char rule_key[RULE_KEY_LEN];
+ char rule_key[RULE_KEY_LEN] = {0};
sprintf(rule_key,"%u_%u_%u",dst_ip,dst_port,src_port);
struct flow_rule *fl = find_rule(rule_key);
diff --git a/src/lstack/netif/lstack_vdev.c b/src/lstack/netif/lstack_vdev.c
index ba0db39..aef6035 100644
--- a/src/lstack/netif/lstack_vdev.c
+++ b/src/lstack/netif/lstack_vdev.c
@@ -152,10 +152,10 @@ int32_t vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple)
}
if (!use_ltran() && get_global_cfg_params()->tuple_filter) {
- if(type == REG_RING_TCP_LISTEN_CLOSE){
+ if (type == REG_RING_TCP_LISTEN_CLOSE) {
if (get_global_cfg_params()->is_primary) {
delete_user_process_port(qtuple->src_port, PORT_LISTEN);
- }else{
+ } else {
transfer_add_or_delete_listen_port_to_process0(qtuple->src_port,get_global_cfg_params()->process_idx, 0);
}
}
@@ -165,10 +165,10 @@ int32_t vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple)
delete_user_process_port(qtuple->src_port, PORT_CONNECT);
uint16_t queue_id = get_protocol_stack()->queue_id;
if (queue_id != 0) {
- delete_flow_director(qtuple->dst_ip, qtuple->src_port, qtuple->dst_port);
+ transfer_delete_rule_info_to_process0(qtuple->dst_ip, qtuple->src_port, qtuple->dst_port);
}
- }else{
- transfer_delete_rule_info_to_process0(qtuple->dst_ip,qtuple->src_port,qtuple->dst_port);
+ } else {
+ transfer_delete_rule_info_to_process0(qtuple->dst_ip, qtuple->src_port, qtuple->dst_port);
}
}
@@ -177,18 +177,18 @@ int32_t vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple)
if (get_global_cfg_params()->is_primary){
add_user_process_port(qtuple->src_port, get_global_cfg_params()->process_idx, PORT_CONNECT);
if (queue_id != 0) {
- config_flow_director(queue_id, qtuple->dst_ip, qtuple->src_ip, qtuple->dst_port, qtuple->src_port);
+ transfer_create_rule_info_to_process0(queue_id, qtuple->src_ip, qtuple->dst_ip, qtuple->src_port, qtuple->dst_port);
}
- }else {
+ } else {
transfer_create_rule_info_to_process0(queue_id, qtuple->src_ip, qtuple->dst_ip, qtuple->src_port, qtuple->dst_port);
}
}
- if (type == REG_RING_TCP_LISTEN){
+ if (type == REG_RING_TCP_LISTEN) {
if (get_global_cfg_params()->is_primary) {
add_user_process_port(qtuple->src_port, get_global_cfg_params()->process_idx, PORT_LISTEN);
- }else {
- transfer_add_or_delete_listen_port_to_process0(qtuple->src_port,get_global_cfg_params()->process_idx, 1);
+ } else {
+ transfer_add_or_delete_listen_port_to_process0(qtuple->src_port, get_global_cfg_params()->process_idx, 1);
}
}
return 0;
@@ -197,7 +197,6 @@ int32_t vdev_reg_xmit(enum reg_ring_type type, struct gazelle_quintuple *qtuple)
return 0;
}
-
int32_t ret;
uint32_t sent_pkts = 0;
void *free_buf[VDEV_REG_QUEUE_SZ];
--
2.23.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/fantaotao1/gazelle.git
git@gitee.com:fantaotao1/gazelle.git
fantaotao1
gazelle
gazelle
master

搜索帮助