1 Star 0 Fork 19

Chenxi Mao/fcoe-utils

forked from src-openEuler/fcoe-utils 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-00-Revert_Make_gcc_compiler_happy_about_ifname_string.patch 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
From 1e6837c8ce063399eeb9580104da33f807e15443 Mon Sep 17 00:00:00 2001
From: Chris Leech <[email protected]>
Date: Tue, 23 Mar 2021 11:16:06 -0700
Subject: [PATCH] Revert "Make gcc compiler happy about ifname string
truncation."
This change dropped the "." from between the physical interface name and
the vlan number, making fipvlan created vlan names incompatible with
fcoeadm commands that ended up calling get_pci_dev_from_netdev in
lib/sysfs_hba.c (fcoeadm -i). That requirement should be fixed, but for
now lets deal with the fipvlan naming regression.
safe_makevlan_name isn't doing anything that can't be handled by
checking the return from snprintf
This reverts commit eee875e6526786031ec916274deec92148677c38.
Signed-off-by: Chris Leech <[email protected]>
---
fipvlan.c | 34 +---------------------------------
1 file changed, 1 insertion(+), 33 deletions(-)
diff --git a/fipvlan.c b/fipvlan.c
index c8a07339314..fe8d7955cc5 100644
--- a/fipvlan.c
+++ b/fipvlan.c
@@ -595,36 +595,6 @@ static int rtnl_listener_handler(struct nlmsghdr *nh, UNUSED void *arg)
return -1;
}
-static int
-safe_makevlan_name(char *vlan_name, size_t vsz,
- char *ifname, int vlan_num, char *suffix)
-{
- size_t ifsz = strlen(ifname);
- size_t susz = strlen(suffix); /* should never be NULL */
- int nusz;
- char numbuf[16];
- char *cp = vlan_name;
-
- nusz = snprintf(numbuf, sizeof(numbuf), "%d", vlan_num);
-
- if ((ifsz + susz + nusz + 2) > vsz) {
- FIP_LOG_ERR(EINVAL,
- "Cannot make VLAN name from ifname=\"%s\", vlan %d, and suffix=\"%s\"\n",
- ifname, vlan_num, suffix);
- return -EINVAL;
- }
- memcpy(cp, ifname, ifsz);
- cp += ifsz;
- memcpy(cp, numbuf, nusz);
- cp += nusz;
- if (susz > 0) {
- memcpy(cp, suffix, susz);
- cp += susz;
- }
- *cp = '\0';
- return 0;
-}
-
static int
create_and_start_vlan(struct fcf *fcf, bool vn2vn)
{
@@ -654,10 +624,8 @@ create_and_start_vlan(struct fcf *fcf, bool vn2vn)
real_dev->ifname, fcf->vlan, vlan->ifname);
rc = 0;
} else {
- rc = safe_makevlan_name(vlan_name, sizeof(vlan_name),
+ snprintf(vlan_name, IFNAMSIZ, "%s.%d%s",
real_dev->ifname, fcf->vlan, config.suffix);
- if (rc < 0)
- return rc;
rc = vlan_create(fcf->ifindex, fcf->vlan, vlan_name);
if (rc < 0)
printf("Failed to create VLAN device %s\n\t%s\n",
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chenxi-mao/fcoe-utils.git
[email protected]:chenxi-mao/fcoe-utils.git
chenxi-mao
fcoe-utils
fcoe-utils
master

搜索帮助