Blame SOURCES/open-lldp-v1.0.1-26-lldpad-system-capability-incorrect-advertised-as-sta.patch

ee47b4
From 036e314bd93602f7388262cc37faf8b626980af1 Mon Sep 17 00:00:00 2001
ee47b4
From: Gary Loughnane <gary.loughnane@intel.com>
ee47b4
Date: Mon, 17 Aug 2015 21:19:24 +0000
ee47b4
Subject: [PATCH] lldpad: system capability incorrect advertised as station
ee47b4
 only
ee47b4
ee47b4
Fix system capability TLV on switch. On our switches we have found
ee47b4
that the system capability was being advertised as Station Only. This
ee47b4
patch changes the capability to Bridge.
ee47b4
ee47b4
Signed-off-by: Gary Loughnane <gary.loughnane@intel.com>
ee47b4
Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
ee47b4
---
ee47b4
 include/lldp_util.h |  1 +
ee47b4
 lldp_util.c         | 22 +++++++++++++++++++++-
ee47b4
 2 files changed, 22 insertions(+), 1 deletion(-)
ee47b4
ee47b4
diff --git a/include/lldp_util.h b/include/lldp_util.h
ee47b4
index 878426b..69b67b1 100644
ee47b4
--- a/include/lldp_util.h
ee47b4
+++ b/include/lldp_util.h
ee47b4
@@ -125,6 +125,7 @@ int is_active(const char *ifname);
ee47b4
 int is_bond(const char *ifname);
ee47b4
 int is_san_mac(u8 *addr);
ee47b4
 int is_bridge(const char *ifname);
ee47b4
+int is_bridge_port(const char *ifname);
ee47b4
 int is_vlan(const char *ifname);
ee47b4
 int is_vlan_capable(const char *ifname);
ee47b4
 int is_wlan(const char *ifname);
ee47b4
diff --git a/lldp_util.c b/lldp_util.c
ee47b4
index f1fb7b9..62f0af8 100644
ee47b4
--- a/lldp_util.c
ee47b4
+++ b/lldp_util.c
ee47b4
@@ -580,6 +580,26 @@ int is_bridge(const char *ifname)
ee47b4
 	return rc;
ee47b4
 }
ee47b4
 
ee47b4
+int is_bridge_port(const char *ifname)
ee47b4
+{
ee47b4
+	int rc = 0;
ee47b4
+	char path[256];
ee47b4
+	DIR *dirp;
ee47b4
+
ee47b4
+	if (!is_ether(ifname)) {
ee47b4
+		return 0;
ee47b4
+	}
ee47b4
+	/* check if the given ifname is a bridge port in sysfs */
ee47b4
+	snprintf(path, sizeof(path), "/sys/class/net/%s/brport/", ifname);
ee47b4
+	dirp = opendir(path);
ee47b4
+	if (dirp) {
ee47b4
+		closedir(dirp);
ee47b4
+		rc = 1;
ee47b4
+	}
ee47b4
+
ee47b4
+	return rc;
ee47b4
+}
ee47b4
+
ee47b4
 int is_vlan(const char *ifname)
ee47b4
 {
ee47b4
 	int fd;
ee47b4
@@ -942,7 +962,7 @@ u16 get_caps(const char *ifname)
ee47b4
 	if (is_vlan(ifname))
ee47b4
 		caps |= SYSCAP_CVLAN;
ee47b4
 
ee47b4
-	if (is_bridge(ifname))
ee47b4
+	if (is_bridge_port(ifname))
ee47b4
 		caps |= SYSCAP_BRIDGE;
ee47b4
 
ee47b4
 	if (is_router())
ee47b4
-- 
ee47b4
2.5.0
ee47b4