Blame SOURCES/0002-Revert-Make-gcc-compiler-happy-about-ifname-string-t.patch

bf9e84
From 1e6837c8ce063399eeb9580104da33f807e15443 Mon Sep 17 00:00:00 2001
bf9e84
From: Chris Leech <cleech@redhat.com>
bf9e84
Date: Tue, 23 Mar 2021 11:16:06 -0700
bf9e84
Subject: [PATCH 2/5] Revert "Make gcc compiler happy about ifname string
bf9e84
 truncation."
bf9e84
bf9e84
This change dropped the "." from between the physical interface name and
bf9e84
the vlan number, making fipvlan created vlan names incompatible with
bf9e84
fcoeadm commands that ended up calling get_pci_dev_from_netdev in
bf9e84
lib/sysfs_hba.c (fcoeadm -i). That requirement should be fixed, but for
bf9e84
now lets deal with the fipvlan naming regression.
bf9e84
bf9e84
safe_makevlan_name isn't doing anything that can't be handled by
bf9e84
checking the return from snprintf
bf9e84
bf9e84
This reverts commit eee875e6526786031ec916274deec92148677c38.
bf9e84
bf9e84
Signed-off-by: Chris Leech <cleech@redhat.com>
bf9e84
---
bf9e84
 fipvlan.c | 34 +---------------------------------
bf9e84
 1 file changed, 1 insertion(+), 33 deletions(-)
bf9e84
bf9e84
diff --git a/fipvlan.c b/fipvlan.c
bf9e84
index c8a07339314..fe8d7955cc5 100644
bf9e84
--- a/fipvlan.c
bf9e84
+++ b/fipvlan.c
bf9e84
@@ -595,36 +595,6 @@ static int rtnl_listener_handler(struct nlmsghdr *nh, UNUSED void *arg)
bf9e84
 	return -1;
bf9e84
 }
bf9e84
 
bf9e84
-static int
bf9e84
-safe_makevlan_name(char *vlan_name, size_t vsz,
bf9e84
-		char *ifname, int vlan_num, char *suffix)
bf9e84
-{
bf9e84
-	size_t ifsz = strlen(ifname);
bf9e84
-	size_t susz = strlen(suffix);	/* should never be NULL */
bf9e84
-	int nusz;
bf9e84
-	char numbuf[16];
bf9e84
-	char *cp = vlan_name;
bf9e84
-
bf9e84
-	nusz = snprintf(numbuf, sizeof(numbuf), "%d", vlan_num);
bf9e84
-
bf9e84
-	if ((ifsz + susz + nusz + 2) > vsz) {
bf9e84
-		FIP_LOG_ERR(EINVAL,
bf9e84
-			"Cannot make VLAN name from ifname=\"%s\", vlan %d, and suffix=\"%s\"\n",
bf9e84
-			ifname, vlan_num, suffix);
bf9e84
-		return -EINVAL;
bf9e84
-	}
bf9e84
-	memcpy(cp, ifname, ifsz);
bf9e84
-	cp += ifsz;
bf9e84
-	memcpy(cp, numbuf, nusz);
bf9e84
-	cp += nusz;
bf9e84
-	if (susz > 0) {
bf9e84
-		memcpy(cp, suffix, susz);
bf9e84
-		cp += susz;
bf9e84
-	}
bf9e84
-	*cp = '\0';
bf9e84
-	return 0;
bf9e84
-}
bf9e84
-
bf9e84
 static int
bf9e84
 create_and_start_vlan(struct fcf *fcf, bool vn2vn)
bf9e84
 {
bf9e84
@@ -654,10 +624,8 @@ create_and_start_vlan(struct fcf *fcf, bool vn2vn)
bf9e84
 				    real_dev->ifname, fcf->vlan, vlan->ifname);
bf9e84
 			rc = 0;
bf9e84
 		} else {
bf9e84
-			rc = safe_makevlan_name(vlan_name, sizeof(vlan_name),
bf9e84
+			snprintf(vlan_name, IFNAMSIZ, "%s.%d%s",
bf9e84
 				 real_dev->ifname, fcf->vlan, config.suffix);
bf9e84
-			if (rc < 0)
bf9e84
-				return rc;
bf9e84
 			rc = vlan_create(fcf->ifindex, fcf->vlan, vlan_name);
bf9e84
 			if (rc < 0)
bf9e84
 				printf("Failed to create VLAN device %s\n\t%s\n",
bf9e84
-- 
bf9e84
2.26.2
bf9e84