File 0032-fipvlan-Fix-crash-in-create_and_start_vlan.patch of Package fcoe-utils

From 0d006642c34e360fb7d3c3adbbb1295e784c03bf Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
Date: Mon, 12 May 2014 14:55:50 +0200
Subject: fipvlan: Fix crash in create_and_start_vlan()

create_and_start_vlan() will issue a netlink command to create
a new VLAN device. As this device isn't present yet we need
to exit here and retry the vlan configuration once we get the
appropriate message from netlink.

References: bnc#877275

Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 fipvlan.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/fipvlan.c b/fipvlan.c
index cc71412..7202f03 100644
--- a/fipvlan.c
+++ b/fipvlan.c
@@ -626,20 +626,21 @@ create_and_start_vlan(struct fcf *fcf, bool vn2vn)
 		vlan = real_dev;
 	} else {
 		vlan = lookup_vlan(fcf->ifindex, fcf->vlan);
-		if (vlan) {
-			FIP_LOG_DBG("VLAN %s.%d already exists as %s\n",
-				    real_dev->ifname, fcf->vlan, vlan->ifname);
+		if (!vlan) {
+			snprintf(vlan_name, IFNAMSIZ, "%s.%d%s",
+				 real_dev->ifname, fcf->vlan, config.suffix);
+			rc = vlan_create(fcf->ifindex, fcf->vlan, vlan_name);
+			if (rc < 0) {
+				printf("Failed to create VLAN device %s\n"
+				       "\t%s\n",
+				       vlan_name, strerror(-rc));
+				return rc;
+			}
+			printf("Created VLAN device %s\n", vlan_name);
 			return 0;
 		}
-		snprintf(vlan_name, IFNAMSIZ, "%s.%d%s",
-			 real_dev->ifname, fcf->vlan, config.suffix);
-		rc = vlan_create(fcf->ifindex, fcf->vlan, vlan_name);
-		if (rc < 0) {
-			printf("Failed to create VLAN device %s\n\t%s\n",
-			       vlan_name, strerror(-rc));
-			return rc;
-		}
-		printf("Created VLAN device %s\n", vlan_name);
+		FIP_LOG_DBG("VLAN %s.%d already exists as %s\n",
+			    real_dev->ifname, fcf->vlan, vlan->ifname);
 	}
 	if (!config.start)
 		return rc;
-- 
1.7.12.4
openSUSE Build Service is sponsored by