File biosdevname_only_ethernet.patch of Package biosdevname.7588

From: Sujith Pandel <sujithpandel@gmail.com>
Subject: Ignore naming of non-Ethernet network interfaces
References: bsc#1042187
Patch-Mainline: 
Git-commit: 609f20c26f40ae4883f5e8c9b241470260722b3f
Git-repo: https://github.com/dell/biosdevname

Support of biosdevname is to name Ethernet interfaces only, as per biosdevname spec.
Currently, manual call of biosdevname on other types of network interfaces will return interface names.
This code change is to ignore naming of Infiniband and other types of network interfaces.

Signed-off-by: Thomas Renninger <trenn@suse.com>

diff --git a/src/bios_device.c b/src/bios_device.c
index 6636e67..e9d5177 100644
--- a/src/bios_device.c
+++ b/src/bios_device.c
@@ -238,6 +238,9 @@ static void match_pci_and_eth_devs(struct libbiosdevname_state *state)
 		/* Loop through all ether devices to find match */
 		unparse_pci_name(pci_name, sizeof(pci_name), p->pci_dev);
 		list_for_each_entry(n, &state->network_devices, node) {
+			//Accept only Ethernet devices, otherwise ignore.
+			if(!netdev_arphrd_type_is_eth(n))
+				continue;
 			if (strncmp(n->drvinfo.bus_info, pci_name, sizeof(n->drvinfo.bus_info)))
 				continue;
 			/* Ignore if devtype is fcoe */
diff --git a/src/eths.h b/src/eths.h
index a145b4f..b695d3d 100644
--- a/src/eths.h
+++ b/src/eths.h
@@ -63,4 +63,9 @@ static inline int netdev_devtype_is_fcoe(const struct network_device *dev)
 	return (dev->devtype_is_fcoe == 1);
 }
 
+static inline int netdev_arphrd_type_is_eth(const struct network_device *dev)
+{
+        return (dev->arphrd_type == ARPHRD_ETHER);
+}
+
 #endif /* __ETHS_H_INCLUDED */
openSUSE Build Service is sponsored by