1 Star 0 Fork 32

hantwofish/gazelle_1

forked from src-openEuler/gazelle 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0201-fix-dpdk_bond_primary_set-bug.patch 2.83 KB
一键复制 编辑 原始数据 按行查看 历史
From c65b58b68bf51cc09d1c2438e55d1dcb92ffd4ca Mon Sep 17 00:00:00 2001
From: zhengjiebing <zhengjiebing_yewu@cmss.chinamobile.com>
Date: Mon, 24 Jun 2024 10:43:50 +0800
Subject: [PATCH] fix dpdk_bond_primary_set bug
---
src/lstack/core/lstack_dpdk.c | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/src/lstack/core/lstack_dpdk.c b/src/lstack/core/lstack_dpdk.c
index b0d76bf..6e52187 100644
--- a/src/lstack/core/lstack_dpdk.c
+++ b/src/lstack/core/lstack_dpdk.c
@@ -509,14 +509,14 @@ static void rss_setup(const int port_id, const uint16_t nb_queues)
free(reta_conf);
}
-int32_t dpdk_bond_primary_set(int port_id, int *slave_port_id)
+int32_t dpdk_bond_primary_set(int port_id, int *slave_port_id, int count)
{
int32_t primary_port_id = ethdev_port_id(get_global_cfg_params()->mac_addr);
if (primary_port_id < 0) {
LSTACK_LOG(ERR, LSTACK, "cannot get the port id of the cfg\n");
return -1;
}
- for (int i = 0; i < GAZELLE_MAX_BOND_NUM; i++) {
+ for (int i = 0; i < count; i++) {
if (slave_port_id[i] == primary_port_id) {
int32_t ret = rte_eth_bond_primary_set(port_id, primary_port_id);
if (ret != 0) {
@@ -715,7 +715,7 @@ static int dpdk_bond_create(uint8_t mode, int *slave_port_id, int count)
}
if (cfg->bond_mode == BONDING_MODE_ACTIVE_BACKUP) {
- ret = dpdk_bond_primary_set(port_id, slave_port_id);
+ ret = dpdk_bond_primary_set(port_id, slave_port_id, count);
if (ret != 0) {
LSTACK_LOG(ERR, LSTACK, "dpdk set bond primary port failed ret = %d\n", ret);
return -1;
@@ -771,7 +771,7 @@ static int dpdk_bond_create(uint8_t mode, int *slave_port_id, int count)
int32_t init_dpdk_ethdev(void)
{
int32_t ret;
- int slave_port_id[GAZELLE_MAX_BOND_NUM] = {-1};
+ int slave_port_id[GAZELLE_MAX_BOND_NUM];
int port_id = 0;
struct cfg_params *cfg = get_global_cfg_params();
int i;
@@ -785,6 +785,10 @@ int32_t init_dpdk_ethdev(void)
} else {
slave_port_id[i] = pci_to_port_id(&cfg->bond_slave_addr[i].addr.pci_addr);
}
+ if (slave_port_id[i] < 0) {
+ LSTACK_LOG(ERR, LSTACK, "cfg->bond_slave_addr[%d] parsing failed, ret=%d\n", i, ret);
+ return -1;
+ }
ret = dpdk_ethdev_init(slave_port_id[i]);
if (ret < 0) {
LSTACK_LOG(ERR, LSTACK, "slave port(%d) init failed, ret=%d\n", slave_port_id[i], ret);
@@ -799,6 +803,9 @@ int32_t init_dpdk_ethdev(void)
}
} else {
port_id = ethdev_port_id(cfg->mac_addr);
+ if (port_id < 0) {
+ return -1;
+ }
ret = dpdk_ethdev_init(port_id);
if (ret != 0) {
LSTACK_LOG(ERR, LSTACK, "dpdk_ethdev_init failed, port id=%d\n", port_id);
--
2.33.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hantwofish/gazelle_1.git
git@gitee.com:hantwofish/gazelle_1.git
hantwofish
gazelle_1
gazelle_1
master

搜索帮助