From 1e6837c8ce063399eeb9580104da33f807e15443 Mon Sep 17 00:00:00 2001 From: Chris Leech Date: Tue, 23 Mar 2021 11:16:06 -0700 Subject: [PATCH 2/5] 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 --- 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", -- 2.26.2